Merged r10992 from trunk (#12400).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11006 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d22f782d3f
commit
82c7dc11d2
|
@ -158,7 +158,13 @@ class CustomField < ActiveRecord::Base
|
|||
possible_values_options = possible_values_options(customized)
|
||||
if possible_values_options.present?
|
||||
keyword = keyword.to_s.downcase
|
||||
possible_values_options.detect {|text, id| text.downcase == keyword}.try(:last)
|
||||
if v = possible_values_options.detect {|text, id| text.downcase == keyword}
|
||||
if v.is_a?(Array)
|
||||
v.last
|
||||
else
|
||||
v
|
||||
end
|
||||
end
|
||||
else
|
||||
keyword
|
||||
end
|
||||
|
|
|
@ -39,3 +39,4 @@ pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
|||
|
||||
category: Stock management
|
||||
searchable field: Value for a custom field
|
||||
Database: postgresql
|
||||
|
|
|
@ -218,4 +218,9 @@ class CustomFieldTest < ActiveSupport::TestCase
|
|||
assert_nil CustomField.new(:field_format => 'text').value_class
|
||||
assert_nil CustomField.new.value_class
|
||||
end
|
||||
|
||||
def test_value_from_keyword_for_list_custom_field
|
||||
field = CustomField.find(1)
|
||||
assert_equal 'PostgreSQL', field.value_from_keyword('postgresql', Issue.find(1))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -177,8 +177,8 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert !issue.new_record?
|
||||
issue.reload
|
||||
assert_equal 'New ticket with custom field values', issue.subject
|
||||
assert_equal 'Value for a custom field',
|
||||
issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
||||
assert_equal 'PostgreSQL', issue.custom_field_value(1)
|
||||
assert_equal 'Value for a custom field', issue.custom_field_value(2)
|
||||
assert !issue.description.match(/^searchable field:/i)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue