From 1d2ec423bbf92c21426e1bc89cd2b3a5e6cab5ae Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 20 Mar 2020 02:35:40 +0000 Subject: [PATCH] Merged r19588 and r19589 from trunk to 4.1-stable (#33085). git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19590 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/enumerations_controller.rb | 2 +- test/functional/enumerations_controller_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index ed5a0e636..a3d4e4756 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -109,7 +109,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 diff --git a/test/functional/enumerations_controller_test.rb b/test/functional/enumerations_controller_test.rb index 079606276..19aed8f98 100644 --- a/test/functional/enumerations_controller_test.rb +++ b/test/functional/enumerations_controller_test.rb @@ -84,6 +84,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 => { -- 2.39.5