From 961c0e0de9537309f73bda6ba47f7c19a008a5fe Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 4 Jun 2016 07:19:20 +0000 Subject: [PATCH] Merged r15429 (#22911). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@15438 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/field_format.rb | 2 +- test/unit/lib/redmine/field_format/enumeration_format_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index c7e8115a6..dd94eeefd 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -715,7 +715,7 @@ module Redmine end def value_from_keyword(custom_field, keyword, object) - value = custom_field.enumerations.where("LOWER(name) LIKE LOWER(?)", keyword) + value = custom_field.enumerations.where("LOWER(name) LIKE LOWER(?)", keyword).first value ? value.id : nil end end diff --git a/test/unit/lib/redmine/field_format/enumeration_format_test.rb b/test/unit/lib/redmine/field_format/enumeration_format_test.rb index a78bdf137..467c1ed9d 100644 --- a/test/unit/lib/redmine/field_format/enumeration_format_test.rb +++ b/test/unit/lib/redmine/field_format/enumeration_format_test.rb @@ -84,4 +84,8 @@ class Redmine::EnumerationFieldFormatTest < ActionView::TestCase end end end + + def test_value_from_keyword_should_return_enumeration_id + assert_equal @foo.id, @field.value_from_keyword('foo', nil) + end end -- 2.39.5