]> git.openstreetmap.org Git - rails.git/commitdiff
Create an empty revoke all blocks page
authorAnton Khorev <tony29@yandex.ru>
Wed, 27 Dec 2023 15:39:17 +0000 (18:39 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 7 Jan 2024 12:15:28 +0000 (15:15 +0300)
app/controllers/user_blocks_controller.rb
app/views/user_blocks/revoke_all.html.erb [new file with mode: 0644]
test/controllers/user_blocks_controller_test.rb

index 885318cbe10ef282762f47939465858767b1e73b..bf61f906b30de4f9a640d8bb18cae40b12ea1d3b 100644 (file)
@@ -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 (file)
index 0000000..e69de29
index efd16f859ad93176978362846b77ae9cf24c42af..ea0e7d48833f3a096f1113a4fbc41912c5b4097c 100644 (file)
@@ -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