]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/confirmations_controller_test.rb
Merge remote-tracking branch 'upstream/pull/5705'
[rails.git] / test / controllers / confirmations_controller_test.rb
index 0f4315e4f339604e33aa608c620a0cfe12f534b0..f7c99a0c6d4cca412d2bd0a3e885b2bef7780e29 100644 (file)
@@ -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
 
@@ -216,35 +204,17 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     email = ActionMailer::Base.deliveries.last
 
     assert_equal user.email, email.to.first
-
-    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 +225,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
 
@@ -278,7 +248,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     confirm_string = user.generate_token_for(:new_email)
 
     post user_confirm_email_path, :params => { :confirm_string => confirm_string }
-    assert_redirected_to edit_account_path
+    assert_redirected_to account_path
     assert_match(/Confirmed your change of email address/, flash[:notice])
   end
 
@@ -287,13 +257,13 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     confirm_string = user.generate_token_for(:new_email)
 
     post user_confirm_email_path, :params => { :confirm_string => confirm_string }
-    assert_redirected_to edit_account_path
+    assert_redirected_to account_path
     assert_match(/already been confirmed/, flash[:error])
   end
 
   def test_confirm_email_bad_token
     post user_confirm_email_path, :params => { :confirm_string => "XXXXX" }
-    assert_redirected_to edit_account_path
+    assert_redirected_to account_path
     assert_match(/confirmation code has expired or does not exist/, flash[:error])
   end
 
@@ -309,7 +279,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     # precondition gravatar should be turned off
     assert_not user.image_use_gravatar
     post user_confirm_email_path, :params => { :confirm_string => confirm_string }
-    assert_redirected_to edit_account_path
+    assert_redirected_to account_path
     assert_match(/Confirmed your change of email address/, flash[:notice])
     # gravatar use should now be enabled
     assert User.find(user.id).image_use_gravatar
@@ -323,7 +293,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
     # precondition gravatar should be turned on
     assert user.image_use_gravatar
     post user_confirm_email_path, :params => { :confirm_string => confirm_string }
-    assert_redirected_to edit_account_path
+    assert_redirected_to account_path
     assert_match(/Confirmed your change of email address/, flash[:notice])
     # gravatar use should now be disabled
     assert_not User.find(user.id).image_use_gravatar