Defect #43603 ยป context_menu_delete_link_with_suburi.patch
| app/controllers/context_menus_controller.rb | ||
|---|---|---|
| 49 | 49 |
begin |
| 50 | 50 |
# Recognize the controller and action from the back_url to determine |
| 51 | 51 |
# which view triggered the context menu. |
| 52 |
route = Rails.application.routes.recognize_path(@back) |
|
| 52 |
if relative_url_root.present? && @back&.starts_with?(relative_url_root) |
|
| 53 |
back = @back.delete_prefix(relative_url_root) |
|
| 54 |
else |
|
| 55 |
back = @back |
|
| 56 |
end |
|
| 57 |
route = Rails.application.routes.recognize_path(back) |
|
| 53 | 58 |
@include_delete = |
| 54 | 59 |
[ |
| 55 | 60 |
{controller: 'issues', action: 'index'},
|
| test/functional/context_menus_controller_test.rb | ||
|---|---|---|
| 492 | 492 |
end |
| 493 | 493 |
end |
| 494 | 494 | |
| 495 |
def test_context_menu_with_suburi_should_include_delete_for_allowed_back_urls |
|
| 496 |
@relative_url_root = Redmine::Utils.relative_url_root |
|
| 497 |
Redmine::Utils.relative_url_root = '/redmine' |
|
| 498 | ||
| 499 |
@request.session[:user_id] = 2 |
|
| 500 |
%w[ |
|
| 501 |
/redmine/issues |
|
| 502 |
/redmine/projects/ecookbook/issues/gantt |
|
| 503 |
/redmine/projects/ecookbook/issues/calendar |
|
| 504 |
].each do |back_url| |
|
| 505 |
get :issues, :params => { :ids => [1], :back_url => back_url }
|
|
| 506 |
assert_response :success |
|
| 507 |
assert_select 'a.icon-del', :text => /Delete/ |
|
| 508 |
end |
|
| 509 |
ensure |
|
| 510 |
Redmine::Utils.relative_url_root = @relative_url_root |
|
| 511 |
end |
|
| 512 | ||
| 495 | 513 |
def test_context_menu_should_not_include_delete_for_disallowed_back_urls |
| 496 | 514 |
@request.session[:user_id] = 2 |
| 497 | 515 |
%w[ |