X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9d2f920feb9dce028b985e8d452538d3df7a1d9c..4dd4831c0aedee97b69fd0c942d559cd0d1f7ed9:/test/controllers/user_roles_controller_test.rb diff --git a/test/controllers/user_roles_controller_test.rb b/test/controllers/user_roles_controller_test.rb index f9e321406..705f06a1c 100644 --- a/test/controllers/user_roles_controller_test.rb +++ b/test/controllers/user_roles_controller_test.rb @@ -31,7 +31,7 @@ class UserRolesControllerTest < ActionController::TestCase # Granting should still fail post :grant, :params => { :display_name => target_user.display_name, :role => "moderator" } - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) assert_equal "Only administrators can perform user role management, and you are not an administrator.", flash[:error] # Login as an administrator @@ -50,20 +50,20 @@ class UserRolesControllerTest < ActionController::TestCase assert_no_difference "UserRole.count" do post :grant, :params => { :display_name => super_user.display_name, :role => role } end - assert_redirected_to user_path(super_user.display_name) + assert_redirected_to user_path(super_user) assert_equal "The user already has role #{role}.", flash[:error] # Granting a role to a user that doesn't have it should work... assert_difference "UserRole.count", 1 do post :grant, :params => { :display_name => target_user.display_name, :role => role } end - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) # ...but trying a second time should fail assert_no_difference "UserRole.count" do post :grant, :params => { :display_name => target_user.display_name, :role => role } end - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) assert_equal "The user already has role #{role}.", flash[:error] end @@ -71,7 +71,7 @@ class UserRolesControllerTest < ActionController::TestCase assert_difference "UserRole.count", 0 do post :grant, :params => { :display_name => target_user.display_name, :role => "no_such_role" } end - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) assert_equal "The string `no_such_role' is not a valid role.", flash[:error] end @@ -92,7 +92,7 @@ class UserRolesControllerTest < ActionController::TestCase # Revoking should still fail post :revoke, :params => { :display_name => target_user.display_name, :role => "moderator" } - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) assert_equal "Only administrators can perform user role management, and you are not an administrator.", flash[:error] # Login as an administrator @@ -111,20 +111,20 @@ class UserRolesControllerTest < ActionController::TestCase assert_no_difference "UserRole.count" do post :revoke, :params => { :display_name => target_user.display_name, :role => role } end - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) assert_equal "The user does not have role #{role}.", flash[:error] # Removing a role from a user that has it should work... assert_difference "UserRole.count", -1 do post :revoke, :params => { :display_name => super_user.display_name, :role => role } end - assert_redirected_to user_path(super_user.display_name) + assert_redirected_to user_path(super_user) # ...but trying a second time should fail assert_no_difference "UserRole.count" do post :revoke, :params => { :display_name => super_user.display_name, :role => role } end - assert_redirected_to user_path(super_user.display_name) + assert_redirected_to user_path(super_user) assert_equal "The user does not have role #{role}.", flash[:error] end @@ -132,12 +132,12 @@ class UserRolesControllerTest < ActionController::TestCase assert_difference "UserRole.count", 0 do post :revoke, :params => { :display_name => target_user.display_name, :role => "no_such_role" } end - assert_redirected_to user_path(target_user.display_name) + assert_redirected_to user_path(target_user) 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_redirected_to user_path(administrator_user) assert_equal "Cannot revoke administrator role from current user.", flash[:error] end end