From 67a5809c8a486b5e8cc92dabd08624afc1a12e6c Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 22 Aug 2024 12:56:15 +0300 Subject: [PATCH 1/1] Show edit buttons on active blocks to all moderators --- app/views/user_blocks/_block.html.erb | 3 +-- app/views/user_blocks/show.html.erb | 3 +-- test/controllers/user_blocks_controller_test.rb | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/user_blocks/_block.html.erb b/app/views/user_blocks/_block.html.erb index 68850c28d..b464b4ccd 100644 --- a/app/views/user_blocks/_block.html.erb +++ b/app/views/user_blocks/_block.html.erb @@ -15,8 +15,7 @@ <% end %> <%= link_to t(".show"), block %> - <% if current_user && (current_user.id == block.creator_id || - current_user.id == block.revoker_id) %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %> + <% if can?(:edit, block) %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %> <% if can?(:revoke, UserBlock) %> <% if block.active? %><%= link_to t(".revoke"), revoke_user_block_path(block) %><% end %> <% end %> diff --git a/app/views/user_blocks/show.html.erb b/app/views/user_blocks/show.html.erb index c36c043cf..06275c3f0 100644 --- a/app/views/user_blocks/show.html.erb +++ b/app/views/user_blocks/show.html.erb @@ -30,8 +30,7 @@ current_user.id == @user_block.revoker_id) || can?(:revoke, UserBlock) && @user_block.active? %>
- <% if current_user && (current_user.id == @user_block.creator_id || - current_user.id == @user_block.revoker_id) %> + <% if can?(:edit, @user_block) %> <%= link_to t(".edit"), edit_user_block_path(@user_block), :class => "btn btn-outline-primary" %> <% end %> <% if can?(:revoke, UserBlock) && @user_block.active? %> diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index a3926cff0..68fc313c3 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -173,7 +173,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest block = create(:user_block, :creator => creator_user) session_for(other_moderator_user) - check_block_buttons block, :revoke => 1 + check_block_buttons block, :edit => 1, :revoke => 1 session_for(creator_user) check_block_buttons block, :edit => 1, :revoke => 1 -- 2.39.5