Merged r24216 from trunk to 6.1-stable (#43603).

git-svn-id: https://svn.redmine.org/redmine/branches/6.1-stable@24219 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2025-12-19 00:58:37 +00:00
parent da723192c7
commit 5194e0b40e
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[