From 3b3478b8a3a3160ef9cdefa205a1ca85f7d2ef08 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 4 Jun 2016 07:19:27 +0000 Subject: [PATCH] Merged r15429 (#22911). git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15439 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 b2aa67931..19e5be5ad 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