]> source.dussan.org Git - redmine.git/commitdiff
Merged r19588 and r19589 from trunk to 4.0-stable (#33085).
authorGo MAEDA <maeda@farend.jp>
Fri, 20 Mar 2020 02:37:33 +0000 (02:37 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 20 Mar 2020 02:37:33 +0000 (02:37 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@19591 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/enumerations_controller.rb
test/functional/enumerations_controller_test.rb

index a04d7b18452a360d73988e47f13cc798a1061600..7a0ab021414cac91d79a0aee9f3ec46db2be65ec 100644 (file)
@@ -107,7 +107,7 @@ class EnumerationsController < ApplicationController
 
   def enumeration_params
     # can't require enumeration on #new action
-    cf_ids = @enumeration.available_custom_fields.map{|c| c.id.to_s}
+    cf_ids = @enumeration.available_custom_fields.map {|c| c.multiple? ? {c.id.to_s => []} : c.id.to_s}
     params.permit(:enumeration => [:name, :active, :is_default, :position, :custom_field_values => cf_ids])[:enumeration]
   end
 end
index 8e411c53e46a7557f4a1151120a118a52c951356..5125e46b2b618851321431ee8aae44e3e13fc20c 100644 (file)
@@ -82,6 +82,21 @@ class EnumerationsControllerTest < Redmine::ControllerTest
     assert_equal "sample", Enumeration.find_by(:name => 'Sample').custom_field_values.last.value
   end
 
+  def test_create_with_multiple_select_list_custom_fields
+    custom_field = IssuePriorityCustomField.generate!(:field_format => 'list', :multiple => true, :possible_values => ['1', '2', '3', '4'])
+    assert_difference 'IssuePriority.count' do
+      post :create, :params => {
+          :enumeration => {
+            :type => 'IssuePriority',
+            :name => 'Sample',
+            :custom_field_values => {custom_field.id.to_s => ['1', '2']}
+          }
+        }
+    end
+    assert_redirected_to '/enumerations'
+    assert_equal ['1', '2'].sort, Enumeration.find_by(:name => 'Sample').custom_field_values.last.value.sort
+  end
+
   def test_create_with_failure
     assert_no_difference 'IssuePriority.count' do
       post :create, :params => {