Bring simple signup flow from the fizzy-saas gem
We skip the QB code and we fill external account ids automatically on creation with a sequence See: https://github.com/basecamp/fizzy-saas/pull/7
This commit is contained in:
@@ -21,14 +21,28 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
sign_in_as :kevin
|
||||
|
||||
test "create for a new user" do
|
||||
untenanted do
|
||||
delete session_path
|
||||
assert_difference -> { Identity.count }, +1 do
|
||||
assert_difference -> { MagicLink.count }, +1 do
|
||||
post session_path,
|
||||
params: { email_address: "nonexistent-#{SecureRandom.hex(6)}@example.com" }
|
||||
end
|
||||
end
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_not cookies[:session_token].present?
|
||||
assert_redirected_to session_magic_link_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
test "destroy" do
|
||||
sign_in_as :kevin
|
||||
|
||||
untenanted do
|
||||
delete session_path
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_not cookies[:session_token].present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
require "test_helper"
|
||||
|
||||
class Signup::CompletionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@signup = Signup.new(email_address: "newuser@example.com", full_name: "New User")
|
||||
|
||||
@signup.create_identity || raise("Failed to create identity")
|
||||
|
||||
sign_in_as @signup.identity
|
||||
end
|
||||
|
||||
test "new" do
|
||||
untenanted do
|
||||
get new_signup_completion_path
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "create" do
|
||||
untenanted do
|
||||
post signup_completion_path, params: {
|
||||
signup: {
|
||||
full_name: @signup.full_name
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_response :redirect, "Valid params should redirect"
|
||||
end
|
||||
|
||||
test "create with invalid params" do
|
||||
untenanted do
|
||||
post signup_completion_path, params: {
|
||||
signup: {
|
||||
full_name: ""
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_response :unprocessable_entity, "Invalid params should return unprocessable entity"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user