From 751e3cd8702314dfc28b7de435f462a3e1f39dbd Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Wed, 4 Mar 2026 10:24:38 +0000 Subject: [PATCH] Add tests for the case of suspended accounts --- .../confirmations_controller_test.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/controllers/confirmations_controller_test.rb b/test/controllers/confirmations_controller_test.rb index 8130c7ce3..27d60a99f 100644 --- a/test/controllers/confirmations_controller_test.rb +++ b/test/controllers/confirmations_controller_test.rb @@ -189,6 +189,24 @@ class ConfirmationsControllerTest < ActionDispatch::IntegrationTest assert_template :no_such_user end + def test_confirm_suspended + user = build(:user, :pending) + stub_gravatar_request(user.email) + post users_path, :params => { :user => user.attributes } + confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) + + User.find_by(:display_name => user.display_name).suspend! + + # Get the confirmation page + get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string } + assert_redirected_to root_path + + # Confirm the user + post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string } + assert_response :not_found + assert_template :no_such_user + end + def test_confirm_resend_success user = build(:user, :pending) post users_path, :params => { :user => user.attributes } @@ -224,6 +242,22 @@ class ConfirmationsControllerTest < ActionDispatch::IntegrationTest assert_match "User #{user.display_name} not found.", flash[:error] end + def test_confirm_resend_suspended + user = build(:user, :pending) + post users_path, :params => { :user => user.attributes } + + User.find_by(:display_name => user.display_name).suspend! + + assert_no_difference "ActionMailer::Base.deliveries.size" do + perform_enqueued_jobs do + post user_confirm_resend_path(user) + end + end + + assert_redirected_to login_path + assert_match "User #{user.display_name} not found.", flash[:error] + end + def test_confirm_resend_unknown_user assert_no_difference "ActionMailer::Base.deliveries.size" do perform_enqueued_jobs do -- 2.39.5