From 633a6fae2a3e3f4f3d3680b93981db61bf040089 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Tue, 3 Aug 2021 20:25:20 +0000 Subject: [PATCH] Update custom field path on the context menu (#33521). Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@21133 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/context_menus_helper.rb | 5 ++- .../context_menus_controller_test.rb | 38 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/helpers/context_menus_helper.rb b/app/helpers/context_menus_helper.rb index b21560c94..4c744b62c 100644 --- a/app/helpers/context_menus_helper.rb +++ b/app/helpers/context_menus_helper.rb @@ -37,10 +37,11 @@ module ContextMenusHelper def bulk_update_custom_field_context_menu_link(field, text, value) context_menu_link( h(text), - bulk_update_issues_path(:ids => @issue_ids, + _bulk_update_issues_path(@issue, + :ids => @issue_ids, :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back), - :method => :post, + :method => :patch, :selected => (@issue && @issue.custom_field_value(field) == value) ) end diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 5600888a9..ccbc4dfba 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -159,8 +159,28 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a[href="#"]', :text => 'List' assert_select 'ul' do assert_select 'a', 3 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + end + end + end + + def test_context_menu_multiple_issues_should_include_list_custom_fields + field = IssueCustomField.create!(:name => 'List', :field_format => 'list', + :possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3]) + @request.session[:user_id] = 2 + get( + :issues, + :params => { + :ids => [1, 2] + } + ) + assert_select "li.cf_#{field.id}" do + assert_select 'a[href="#"]', :text => 'List' + assert_select 'ul' do + assert_select 'a', 3 + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -220,9 +240,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a[href="#"]', :text => 'Bool' assert_select 'ul' do assert_select 'a', 3 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -241,8 +261,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a[href="#"]', :text => 'User' assert_select 'ul' do assert_select 'a', Project.find(1).members.count + 2 # users + 'none' + 'me' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -260,8 +280,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a[href="#"]', :text => 'Version' assert_select 'ul' do assert_select 'a', Project.find(1).shared_versions.count + 1 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0' + assert_select 'a[href=?]', "/issues/1?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end -- 2.39.5