1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Delete link is missing from the context menu when using a relative URL root (#43603).

Patch by Kenta Kumojima (user:kumojima).


git-svn-id: https://svn.redmine.org/redmine/trunk@24216 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2025-12-18 11:18:21 +00:00
parent 43f72bb6f2
commit e31e2a19e9
2 changed files with 24 additions and 1 deletions

View File

@ -49,7 +49,12 @@ class ContextMenusController < ApplicationController
begin
# Recognize the controller and action from the back_url to determine
# which view triggered the context menu.
route = Rails.application.routes.recognize_path(@back)
if relative_url_root.present? && back_url&.starts_with?(relative_url_root)
normalized_back_url = back_url.delete_prefix(relative_url_root)
else
normalized_back_url = back_url
end
route = Rails.application.routes.recognize_path(normalized_back_url)
@include_delete =
[
{controller: 'issues', action: 'index'},

View File

@ -492,6 +492,24 @@ class ContextMenusControllerTest < Redmine::ControllerTest
end
end
def test_context_menu_with_suburi_should_include_delete_for_allowed_back_urls
@relative_url_root = Redmine::Utils.relative_url_root
Redmine::Utils.relative_url_root = '/redmine'
@request.session[:user_id] = 2
%w[
/redmine/issues
/redmine/projects/ecookbook/issues/gantt
/redmine/projects/ecookbook/issues/calendar
].each do |back_url|
get :issues, :params => { :ids => [1], :back_url => back_url }
assert_response :success
assert_select 'a.icon-del', :text => /Delete/
end
ensure
Redmine::Utils.relative_url_root = @relative_url_root
end
def test_context_menu_should_not_include_delete_for_disallowed_back_urls
@request.session[:user_id] = 2
%w[