From 54a12ccb6972f382d0129f6d75cb2e8707fb560a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 24 May 2014 16:38:36 +0000 Subject: [PATCH] Merged r13141 (#16926). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13163 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/field_format.rb | 5 +++-- .../lib/redmine/field_format/version_field_format_test.rb | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 3b567a0b8..655e2c984 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -98,9 +98,10 @@ module Redmine if value.blank? nil elsif value.is_a?(Array) - value.map do |v| + casted = value.map do |v| cast_single_value(custom_field, v, customized) - end.sort + end + casted.compact.sort else cast_single_value(custom_field, value, customized) end diff --git a/test/unit/lib/redmine/field_format/version_field_format_test.rb b/test/unit/lib/redmine/field_format/version_field_format_test.rb index 50e0e3786..f7fc72a03 100644 --- a/test/unit/lib/redmine/field_format/version_field_format_test.rb +++ b/test/unit/lib/redmine/field_format/version_field_format_test.rb @@ -56,4 +56,11 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase assert_equal expected, field.possible_values_options(project).map(&:first) end + + def test_cast_value_should_not_raise_error_when_array_contains_value_casted_to_nil + field = IssueCustomField.new(:field_format => 'version') + assert_nothing_raised do + field.cast_value([1,2, 42]) + end + end end -- 2.39.5