From: Anton Khorev Date: Fri, 23 Aug 2024 10:34:08 +0000 (+0300) Subject: Remove revoke block action X-Git-Tag: live~246^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/258104dfdfba612a1b507e040b072d417e5f8576?hp=-c Remove revoke block action --- 258104dfdfba612a1b507e040b072d417e5f8576 diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 6baa67be5..7ee75f3bc 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -60,7 +60,7 @@ class Ability can [:index, :show, :resolve, :ignore, :reopen], Issue can :create, IssueComment can [:new, :create, :edit, :update, :destroy], Redaction - can [:new, :create, :revoke, :revoke_all], UserBlock + can [:new, :create, :revoke_all], UserBlock can :update, UserBlock, :creator => user can :update, UserBlock, :revoker => user can :update, UserBlock, :active? => true diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 7027359cc..6bf86de3f 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -10,10 +10,10 @@ class UserBlocksController < ApplicationController authorize_resource before_action :lookup_user, :only => [:new, :create, :revoke_all, :blocks_on, :blocks_by] - before_action :lookup_user_block, :only => [:show, :edit, :update, :revoke] + before_action :lookup_user_block, :only => [:show, :edit, :update] before_action :require_valid_params, :only => [:create, :update] before_action :check_database_readable - before_action :check_database_writable, :only => [:create, :update, :revoke, :revoke_all] + before_action :check_database_writable, :only => [:create, :update, :revoke_all] def index @params = params.permit @@ -105,15 +105,6 @@ class UserBlocksController < ApplicationController end end - ## - # revokes the block, setting the end_time to now - def revoke - if request.post? && params[:confirm] && @user_block.revoke!(current_user) - flash[:notice] = t ".flash" - redirect_to(@user_block) - end - end - ## # revokes all active blocks def revoke_all diff --git a/config/locales/en.yml b/config/locales/en.yml index 215a96179..36698f02c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2958,8 +2958,6 @@ en: title: "User blocks" heading: "List of user blocks" empty: "No blocks have been made yet." - revoke: - flash: "This block has been revoked." revoke_all: title: "Revoking all blocks on %{block_on}" heading_html: "Revoking all blocks on %{block_on}" diff --git a/config/routes.rb b/config/routes.rb index b6522a1ab..b0e23301e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -334,7 +334,6 @@ OpenStreetMap::Application.routes.draw do get "/user/:display_name/blocks_by" => "user_blocks#blocks_by", :as => "user_blocks_by" get "/blocks/new/:display_name" => "user_blocks#new", :as => "new_user_block" resources :user_blocks, :except => :new - post "/blocks/:id/revoke" => "user_blocks#revoke", :as => "revoke_user_block" match "/user/:display_name/blocks/revoke_all" => "user_blocks#revoke_all", :via => [:get, :post], :as => "revoke_all_user_blocks" # issues and reports diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index 6d99db1cd..ed310f52e 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -33,10 +33,6 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest { :path => "/user_blocks/1", :method => :delete }, { :controller => "user_blocks", :action => "destroy", :id => "1" } ) - assert_routing( - { :path => "/blocks/1/revoke", :method => :post }, - { :controller => "user_blocks", :action => "revoke", :id => "1" } - ) assert_routing( { :path => "/user/username/blocks", :method => :get }, @@ -549,21 +545,6 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest assert_equal other_moderator_user, block.revoker end - ## - # test the revoke action - def test_revoke - active_block = create(:user_block) - - # Login as a moderator - session_for(create(:moderator_user)) - - # Check that revoking a block works using POST - post revoke_user_block_path(:id => active_block, :confirm => true) - assert_redirected_to user_block_path(active_block) - b = UserBlock.find(active_block.id) - assert_in_delta Time.now.utc, b.ends_at, 1 - end - ## # test the revoke all page def test_revoke_all_page