@@ -126,6 +126,16 class CustomField < ActiveRecord::Base | |||
|
126 | 126 | casted |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | def value_from_keyword(keyword, customized) | |
|
130 | possible_values_options = possible_values_options(customized) | |
|
131 | if possible_values_options.present? | |
|
132 | keyword = keyword.to_s.downcase | |
|
133 | possible_values_options.detect {|text, id| text.downcase == keyword}.try(:last) | |
|
134 | else | |
|
135 | keyword | |
|
136 | end | |
|
137 | end | |
|
138 | ||
|
129 | 139 | # Returns a ORDER BY clause that can used to sort customized |
|
130 | 140 | # objects by their value of the custom field. |
|
131 | 141 | # Returns nil if the custom field can not be used for sorting. |
@@ -342,8 +342,8 class MailHandler < ActionMailer::Base | |||
|
342 | 342 | # Returns a Hash of issue custom field values extracted from keywords in the email body |
|
343 | 343 | def custom_field_values_from_keywords(customized) |
|
344 | 344 | customized.custom_field_values.inject({}) do |h, v| |
|
345 |
if |
|
|
346 | h[v.custom_field.id.to_s] = value | |
|
345 | if keyword = get_keyword(v.custom_field.name, :override => true) | |
|
346 | h[v.custom_field.id.to_s] = v.custom_field.value_from_keyword(keyword, customized) | |
|
347 | 347 | end |
|
348 | 348 | h |
|
349 | 349 | end |
@@ -182,6 +182,18 class MailHandlerTest < ActiveSupport::TestCase | |||
|
182 | 182 | assert !issue.description.match(/^searchable field:/i) |
|
183 | 183 | end |
|
184 | 184 | |
|
185 | def test_add_issue_with_version_custom_fields | |
|
186 | field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1,2,3]) | |
|
187 | ||
|
188 | issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'ecookbook'}) do |email| | |
|
189 | email << "Affected version: 1.0\n" | |
|
190 | end | |
|
191 | assert issue.is_a?(Issue) | |
|
192 | assert !issue.new_record? | |
|
193 | issue.reload | |
|
194 | assert_equal '2', issue.custom_field_value(field) | |
|
195 | end | |
|
196 | ||
|
185 | 197 | def test_add_issue_with_cc |
|
186 | 198 | issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) |
|
187 | 199 | assert issue.is_a?(Issue) |
General Comments 0
You need to be logged in to leave comments.
Login now