diff options
-rw-r--r-- | lib/redmine/field_format.rb | 2 | ||||
-rw-r--r-- | test/unit/lib/redmine/field_format/enumeration_format_test.rb | 4 |
2 files changed, 5 insertions, 1 deletions
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 |