]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/accounts_controller_test.rb
Test account destroy route
[rails.git] / test / controllers / accounts_controller_test.rb
index 131292f412d90f286b8798b81b84bde1015b2be4..f13574213a7fdcc5927aebc63f0eb343f32a8692 100644 (file)
@@ -12,6 +12,10 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
       { :path => "/account", :method => :put },
       { :controller => "accounts", :action => "update" }
     )
+    assert_routing(
+      { :path => "/account", :method => :delete },
+      { :controller => "accounts", :action => "destroy" }
+    )
   end
 
   def test_account
@@ -25,7 +29,6 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     # Make sure that you are redirected to the login page when
     # you are not logged in
     get edit_account_path
-    assert_response :redirect
     assert_redirected_to login_path(:referer => "/account/edit")
 
     # Make sure we get the page when we are logged in as the right user
@@ -49,10 +52,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
 
     # Adding external authentication should redirect to the auth provider
     patch account_path, :params => { :user => user.attributes.merge(:auth_provider => "google") }
-    assert_response :redirect
     assert_redirected_to auth_path(:provider => "google", :origin => "/account")
     follow_redirect!
-    assert_response :redirect
     assert_redirected_to %r{^https://accounts.google.com/o/oauth2/auth\?.*}
 
     # Changing name to one that exists should fail
@@ -74,9 +75,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     # Changing name to one that doesn't exist should work
     new_attributes = user.attributes.dup.merge(:display_name => "new tester")
     patch account_path, :params => { :user => new_attributes }
-    assert_response :redirect
-    assert_redirected_to edit_account_url
-    get edit_account_path
+    assert_redirected_to edit_account_path
+    follow_redirect!
     assert_response :success
     assert_template :edit
     assert_select ".alert-success", /^User information updated successfully/
@@ -116,9 +116,8 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
         patch account_path, :params => { :user => user.attributes }
       end
     end
-    assert_response :redirect
-    assert_redirected_to edit_account_url
-    get edit_account_path
+    assert_redirected_to edit_account_path
+    follow_redirect!
     assert_response :success
     assert_template :edit
     assert_select ".alert-success", /^User information updated successfully/
@@ -126,7 +125,6 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     email = ActionMailer::Base.deliveries.first
     assert_equal 1, email.to.count
     assert_equal user.new_email, email.to.first
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_private_account
@@ -135,7 +133,6 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
     # Make sure that you are redirected to the login page when
     # you are not logged in
     get edit_account_path
-    assert_response :redirect
     assert_redirected_to login_path(:referer => "/account/edit")
 
     # Make sure we get the page when we are logged in as the right user