Split tests by controller or responsibility

This commit is contained in:
Stanko K.R.
2025-12-16 18:38:11 +01:00
parent 1a1f4a077b
commit 23fc7b594f
4 changed files with 115 additions and 118 deletions
@@ -86,4 +86,35 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
assert_not cookies[:session_token].present?
end
end
test "create via JSON" do
untenanted do
post session_path(format: :json), params: { email_address: identities(:david).email_address }
assert_response :created
end
end
test "create for a new user via JSON" do
new_email = "new-user-#{SecureRandom.hex(6)}@example.com"
untenanted do
assert_difference -> { Identity.count }, 1 do
assert_difference -> { MagicLink.count }, 1 do
post session_path(format: :json), params: { email_address: new_email }
end
end
assert_response :created
assert @response.parsed_body["pending_authentication_token"].present?
assert MagicLink.last.for_sign_up?
end
end
test "create with invalid email address via JSON" do
untenanted do
assert_no_difference -> { Identity.count } do
post session_path(format: :json), params: { email_address: "not-a-valid-email" }
end
assert_response :unprocessable_entity
end
end
end