]> source.dussan.org Git - redmine.git/commitdiff
NoMethodError: undefined method `id' error on EnumerationFormat#value_from_keyword...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 May 2016 11:37:28 +0000 (11:37 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 May 2016 11:37:28 +0000 (11:37 +0000)
Patch by Haihan Ji.

git-svn-id: http://svn.redmine.org/redmine/trunk@15429 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/field_format.rb
test/unit/lib/redmine/field_format/enumeration_format_test.rb

index c7e8115a6140580d9bed62f90573f8f9a2d080f8..dd94eeefdd3df9294c098bf670e79adda45882c1 100644 (file)
@@ -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
index a78bdf1379d8ed6921bfc2bab9c1ad16f9269d14..467c1ed9d87f3503a12ae1d98da5f81341f99009 100644 (file)
@@ -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