]> source.dussan.org Git - redmine.git/commitdiff
Update custom field path on the context menu (#33521).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 3 Aug 2021 20:25:20 +0000 (20:25 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 3 Aug 2021 20:25:20 +0000 (20:25 +0000)
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
test/functional/context_menus_controller_test.rb

index b21560c94d035c18fee9207ede7a5606214bf937..4c744b62c131c099dbac3523ea092ab95e3eb86f 100644 (file)
@@ -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
index 5600888a943ede574ff105ae733016dce4341a8a..ccbc4dfba344dc7d7e22e20997ebea243df679b5 100644 (file)
@@ -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