]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/user_roles_controller_test.rb
use a controller method to handle cancan denials
[rails.git] / test / controllers / user_roles_controller_test.rb
index f73fc9056293571f54845211fb60575cf664fcb0..f9e32140621081672573fd07ae88477a9ba5a998 100644 (file)
@@ -134,5 +134,10 @@ class UserRolesControllerTest < ActionController::TestCase
     end
     assert_redirected_to user_path(target_user.display_name)
     assert_equal "The string `no_such_role' is not a valid role.", flash[:error]
     end
     assert_redirected_to user_path(target_user.display_name)
     assert_equal "The string `no_such_role' is not a valid role.", flash[:error]
+
+    # Revoking administrator role from current user should fail
+    post :revoke, :params => { :display_name => administrator_user.display_name, :role => "administrator" }
+    assert_redirected_to user_path(administrator_user.display_name)
+    assert_equal "Cannot revoke administrator role from current user.", flash[:error]
   end
 end
   end
 end