From d88cb014cb21ab88419eb48045d3daec96ec9093 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 25 Jul 2024 04:05:31 +0300 Subject: [PATCH] Show edit links for revoked blocks to revokers --- app/views/user_blocks/_block.html.erb | 3 ++- app/views/user_blocks/show.html.erb | 7 +++++-- test/controllers/user_blocks_controller_test.rb | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/user_blocks/_block.html.erb b/app/views/user_blocks/_block.html.erb index 461dc7a8d..a18d1dbdb 100644 --- a/app/views/user_blocks/_block.html.erb +++ b/app/views/user_blocks/_block.html.erb @@ -15,7 +15,8 @@ <% end %> <%= link_to t(".show"), block %> - <% if current_user and current_user.id == block.creator_id %><%= link_to t(".edit"), edit_user_block_path(block) %><% end %> + <% 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 show_revoke_link %> <% 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 619cd6c3f..c36c043cf 100644 --- a/app/views/user_blocks/show.html.erb +++ b/app/views/user_blocks/show.html.erb @@ -26,9 +26,12 @@
<%= @user_block.reason.to_html %>
-<% if current_user&.id == @user_block.creator_id || can?(:revoke, UserBlock) && @user_block.active? %> +<% if current_user && (current_user.id == @user_block.creator_id || + current_user.id == @user_block.revoker_id) || + can?(:revoke, UserBlock) && @user_block.active? %>
- <% if current_user&.id == @user_block.creator_id %> + <% if current_user && (current_user.id == @user_block.creator_id || + current_user.id == @user_block.revoker_id) %> <%= 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 dd0b1287b..d164d6aef 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -212,7 +212,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest check_block_buttons block, :edit => 1 session_for(revoker_user) - check_block_buttons block + check_block_buttons block, :edit => 1 end private -- 2.39.5