Defect #43603 ยป context_menu_delete_link_with_suburi.patch
| app/controllers/context_menus_controller.rb | ||
|---|---|---|
|
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&.starts_with?(relative_url_root)
|
||
|
back = @back.delete_prefix(relative_url_root)
|
||
|
else
|
||
|
back = @back
|
||
|
end
|
||
|
route = Rails.application.routes.recognize_path(back)
|
||
|
@include_delete =
|
||
|
[
|
||
|
{controller: 'issues', action: 'index'},
|
||
| test/functional/context_menus_controller_test.rb | ||
|---|---|---|
|
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[
|
||