Feature #16549 » set_multiple_values_via_email.diff
| lib/redmine/field_format.rb | ||
|---|---|---|
|
possible_values_options = possible_values_options(custom_field, object)
|
||
|
if possible_values_options.present?
|
||
|
keyword = keyword.to_s
|
||
|
if v = possible_values_options.detect {|text, id| keyword.casecmp(text) == 0}
|
||
|
if custom_field.multiple?
|
||
|
possible_options = possible_values_options.collect {|option, value| option}
|
||
|
keywords_re =
|
||
|
/
|
||
|
(?:\A|,\s*) # Start of the line or separator (,) and some whitespace
|
||
|
(#{Regexp.union(possible_options).source}) # one of the possible options
|
||
|
\s* # some whitespace before either the next separator (,) or the end
|
||
|
/xi
|
||
|
result = []
|
||
|
keyword.scan(keywords_re) do |match|
|
||
|
v = possible_values_options.detect {|text, id| match.first.casecmp(text) == 0}
|
||
|
v = v.last if v.is_a?(Array)
|
||
|
result << v
|
||
|
end
|
||
|
result = result.uniq
|
||
|
elsif v = possible_values_options.detect {|text, id| keyword.casecmp(text) == 0}
|
||
|
if v.is_a?(Array)
|
||
|
v.last
|
||
|
result = v.last
|
||
|
else
|
||
|
v
|
||
|
result = v
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
keyword
|
||
|
result = keyword
|
||
|
end
|
||
|
result
|
||
|
end
|
||
|
# Returns the validation errors for custom_field
|
||
| test/fixtures/custom_fields.yml | ||
|---|---|---|
|
- Other value
|
||
|
field_format: list
|
||
|
position: 1
|
||
|
custom_fields_012:
|
||
|
id: 12
|
||
|
name: OS
|
||
|
type: IssueCustomField
|
||
|
possible_values:
|
||
|
- Linux
|
||
|
- Windows
|
||
|
- Mac OS X
|
||
|
field_format: list
|
||
|
multiple: true
|
||
|
position: 1
|
||
| test/fixtures/custom_fields_projects.yml | ||
|---|---|---|
|
custom_fields_projects_001:
|
||
|
custom_field_id: 9
|
||
|
project_id: 1
|
||
|
custom_fields_projects_002:
|
||
|
custom_field_id: 12
|
||
|
project_id: 2
|
||
| test/fixtures/custom_fields_trackers.yml | ||
|---|---|---|
|
custom_fields_trackers_010:
|
||
|
custom_field_id: 9
|
||
|
tracker_id: 1
|
||
|
custom_fields_trackers_011:
|
||
|
custom_field_id: 12
|
||
|
tracker_id: 1
|
||
| test/fixtures/mail_handler/ticket_with_custom_fields.eml | ||
|---|---|---|
|
category: Stock management
|
||
|
searchable field: Value for a custom field
|
||
|
Database: postgresql
|
||
|
OS: Mac OS X ,windows
|
||
| test/unit/mail_handler_test.rb | ||
|---|---|---|
|
def test_add_issue_with_custom_fields
|
||
|
issue = submit_email('ticket_with_custom_fields.eml',
|
||
|
:issue => {:project => 'onlinestore'}, :allow_override => ['database', 'Searchable_field']
|
||
|
:issue => {:project => 'onlinestore'}, :allow_override => ['database', 'Searchable_field', 'OS']
|
||
|
)
|
||
|
assert issue.is_a?(Issue)
|
||
|
assert !issue.new_record?
|
||
| ... | ... | |
|
assert_equal 'New ticket with custom field values', issue.subject
|
||
|
assert_equal 'PostgreSQL', issue.custom_field_value(1)
|
||
|
assert_equal 'Value for a custom field', issue.custom_field_value(2)
|
||
|
assert_equal ["Mac OS X", "Windows"], issue.custom_field_value(12).sort
|
||
|
assert !issue.description.match(/^searchable field:/i)
|
||
|
end
|
||
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »