From: Anton Khorev Date: Wed, 27 Dec 2023 15:39:17 +0000 (+0300) Subject: Create an empty revoke all blocks page X-Git-Tag: live~879^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ba53dc7b04b4f081f748f2c506b25a3a6563f63d?ds=inline;hp=-c Create an empty revoke all blocks page --- ba53dc7b04b4f081f748f2c506b25a3a6563f63d diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 885318cbe..bf61f906b 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -89,6 +89,12 @@ class UserBlocksController < ApplicationController end end + ## + # revokes all active blocks + def revoke_all + # TODO revoke + end + ## # shows a list of all the blocks on the given user def blocks_on diff --git a/app/views/user_blocks/revoke_all.html.erb b/app/views/user_blocks/revoke_all.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index efd16f859..ea0e7d488 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -394,6 +394,36 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest assert_select "p", "Sorry, the user block with ID 99999 could not be found." end + ## + # test the revoke all action + def test_revoke_all + blocked_user = create(:user) + create(:user_block, :user => blocked_user) + + # Asking for the revoke all blocks page with a bogus user name should fail + get user_blocks_on_path(:display_name => "non_existent_user") + assert_response :not_found + + # Check that the revoke all blocks page requires us to login + get revoke_all_user_blocks_path(blocked_user) + assert_redirected_to login_path(:referer => revoke_all_user_blocks_path(blocked_user)) + + # Login as a normal user + session_for(create(:user)) + + # Check that normal users can't load the revoke all blocks page + get revoke_all_user_blocks_path(blocked_user) + assert_response :redirect + assert_redirected_to :controller => "errors", :action => "forbidden" + + # Login as a moderator + session_for(create(:moderator_user)) + + # Check that the revoke all blocks page loads for moderators + get revoke_all_user_blocks_path(blocked_user) + assert_response :success + end + ## # test the blocks_on action def test_blocks_on