X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e0d0b68785bd1a765b796a826eeeb2782f841ada..fdb3a7a102f5c9c438542e6edcf042dbbfda2e07:/test/controllers/confirmations_controller_test.rb?ds=sidebyside diff --git a/test/controllers/confirmations_controller_test.rb b/test/controllers/confirmations_controller_test.rb index 0f4315e4f..774efdb9c 100644 --- a/test/controllers/confirmations_controller_test.rb +++ b/test/controllers/confirmations_controller_test.rb @@ -13,7 +13,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest { :controller => "confirmations", :action => "confirm", :display_name => "username" } ) assert_routing( - { :path => "/user/username/confirm/resend", :method => :get }, + { :path => "/user/username/confirm/resend", :method => :post }, { :controller => "confirmations", :action => "confirm_resend", :display_name => "username" } ) @@ -37,8 +37,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_get user = build(:user, :pending) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string } @@ -49,8 +48,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_get_already_confirmed user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) # Get the confirmation page @@ -70,8 +68,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_no_token_no_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post logout_path @@ -84,8 +81,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_good_token_no_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string } @@ -95,8 +91,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_bad_token_no_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post logout_path @@ -110,8 +105,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_no_token_with_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post logout_path @@ -124,8 +118,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_good_token_with_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path } @@ -135,8 +128,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_success_bad_token_with_referer user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post logout_path @@ -150,8 +142,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_expired_token user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) travel 2.weeks do @@ -164,8 +155,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_already_confirmed user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user) post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path } @@ -182,8 +172,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_deleted user = build(:user, :pending) stub_gravatar_request(user.email) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + 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).hide! @@ -200,12 +189,11 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_resend_success user = build(:user, :pending) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } assert_difference "ActionMailer::Base.deliveries.size", 1 do perform_enqueued_jobs do - get user_confirm_resend_path(user) + post user_confirm_resend_path(user) end end @@ -220,31 +208,15 @@ class UsersControllerTest < ActionDispatch::IntegrationTest ActionMailer::Base.deliveries.clear end - def test_confirm_resend_no_token - user = build(:user, :pending) - # only complete first half of registration - post user_new_path, :params => { :user => user.attributes } - - assert_no_difference "ActionMailer::Base.deliveries.size" do - perform_enqueued_jobs do - get 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_deleted user = build(:user, :pending) - post user_new_path, :params => { :user => user.attributes } - post user_save_path, :params => { :read_ct => 1, :read_tou => 1 } + post users_path, :params => { :user => user.attributes } User.find_by(:display_name => user.display_name).hide! assert_no_difference "ActionMailer::Base.deliveries.size" do perform_enqueued_jobs do - get user_confirm_resend_path(user) + post user_confirm_resend_path(user) end end @@ -255,7 +227,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_resend_unknown_user assert_no_difference "ActionMailer::Base.deliveries.size" do perform_enqueued_jobs do - get user_confirm_resend_path(:display_name => "No Such User") + post user_confirm_resend_path(:display_name => "No Such User") end end