X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/5e407dfb34f47e6fbbbf3c11c1a8318256abb5cd..64b3e289ac14533c6fb2b1223b6417ad0446878c:/test/controllers/user_blocks_controller_test.rb diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index 62eee71a6..5338858f7 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -120,7 +120,7 @@ class UserBlocksControllerTest < ActionController::TestCase # Viewing an active block should work, but shouldn't mark it as seen get :show, :params => { :id => active_block.id } assert_response :success - assert_equal true, UserBlock.find(active_block.id).needs_view + assert UserBlock.find(active_block.id).needs_view # Login as the blocked user session[:user] = active_block.user.id @@ -128,7 +128,7 @@ class UserBlocksControllerTest < ActionController::TestCase # Now viewing it should mark it as seen get :show, :params => { :id => active_block.id } assert_response :success - assert_equal false, UserBlock.find(active_block.id).needs_view + assert_not UserBlock.find(active_block.id).needs_view end ## @@ -145,8 +145,8 @@ class UserBlocksControllerTest < ActionController::TestCase # Check that normal users can't load the block creation page get :new, :params => { :display_name => target_user.display_name } - assert_redirected_to user_blocks_path - assert_equal "You need to be a moderator to perform that action.", flash[:error] + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" # Login as a moderator session[:user] = create(:moderator_user).id @@ -165,13 +165,13 @@ class UserBlocksControllerTest < ActionController::TestCase # We should get an error if no user is specified get :new assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user does not exist" # We should get an error if the user doesn't exist get :new, :params => { :display_name => "non_existent_user" } assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user non_existent_user does not exist" end @@ -189,8 +189,8 @@ class UserBlocksControllerTest < ActionController::TestCase # Check that normal users can't load the block edit page get :edit, :params => { :id => active_block.id } - assert_redirected_to user_blocks_path - assert_equal "You need to be a moderator to perform that action.", flash[:error] + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" # Login as a moderator session[:user] = create(:moderator_user).id @@ -232,7 +232,8 @@ class UserBlocksControllerTest < ActionController::TestCase # Check that normal users can't create blocks post :create - assert_response :forbidden + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" # Login as a moderator session[:user] = moderator_user.id @@ -260,7 +261,7 @@ class UserBlocksControllerTest < ActionController::TestCase assert_in_delta Time.now, b.created_at, 1 assert_in_delta Time.now, b.updated_at, 1 assert_in_delta Time.now + 12.hours, b.ends_at, 1 - assert_equal false, b.needs_view + assert_not b.needs_view assert_equal "Vandalism", b.reason assert_equal "markdown", b.reason_format assert_equal moderator_user.id, b.creator_id @@ -268,13 +269,13 @@ class UserBlocksControllerTest < ActionController::TestCase # We should get an error if no user is specified post :create assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user does not exist" # We should get an error if the user doesn't exist post :create, :params => { :display_name => "non_existent_user" } assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user non_existent_user does not exist" end @@ -294,7 +295,8 @@ class UserBlocksControllerTest < ActionController::TestCase # Check that normal users can't update blocks put :update, :params => { :id => active_block.id } - assert_response :forbidden + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" # Login as the wrong moderator session[:user] = second_moderator_user.id @@ -332,7 +334,7 @@ class UserBlocksControllerTest < ActionController::TestCase assert_equal "Block updated.", flash[:notice] b = UserBlock.find(active_block.id) assert_in_delta Time.now, b.updated_at, 1 - assert_equal true, b.needs_view + assert b.needs_view assert_equal "Vandalism", b.reason # We should get an error if no block ID is specified @@ -361,8 +363,8 @@ class UserBlocksControllerTest < ActionController::TestCase # Check that normal users can't load the block revoke page get :revoke, :params => { :id => active_block.id } - assert_redirected_to user_blocks_path - assert_equal "You need to be a moderator to perform that action.", flash[:error] + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" # Login as a moderator session[:user] = create(:moderator_user).id @@ -412,7 +414,7 @@ class UserBlocksControllerTest < ActionController::TestCase # Asking for a list of blocks with a bogus user name should fail get :blocks_on, :params => { :display_name => "non_existent_user" } assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user non_existent_user does not exist" # Check the list of blocks for a user that has never been blocked @@ -476,7 +478,7 @@ class UserBlocksControllerTest < ActionController::TestCase # Asking for a list of blocks with a bogus user name should fail get :blocks_by, :params => { :display_name => "non_existent_user" } assert_response :not_found - assert_template "user/no_such_user" + assert_template "users/no_such_user" assert_select "h1", "The user non_existent_user does not exist" # Check the list of blocks given by one moderator