summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/mail_handler.rb15
-rw-r--r--test/unit/mail_handler_test.rb5
2 files changed, 16 insertions, 4 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index ea9671ff6..8e19bcdf4 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -203,10 +203,17 @@ class MailHandler < ActionMailer::Base
end
def get_keyword(attr, options={})
- if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
- $1.strip
- elsif !@@handler_options[:issue][attr].blank?
- @@handler_options[:issue][attr]
+ @keywords ||= {}
+ if @keywords.has_key?(attr)
+ @keywords[attr]
+ else
+ @keywords[attr] = begin
+ if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '')
+ $1.strip
+ elsif !@@handler_options[:issue][attr].blank?
+ @@handler_options[:issue][attr]
+ end
+ end
end
end
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 678ba520f..4ec9684a0 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -49,7 +49,11 @@ class MailHandlerTest < Test::Unit::TestCase
assert_equal 'New ticket on a given project', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
+ assert_equal IssueStatus.find_by_name('Resolved'), issue.status
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+ # keywords should be removed from the email body
+ assert !issue.description.match(/^Project:/i)
+ assert !issue.description.match(/^Status:/i)
end
def test_add_issue_with_status
@@ -113,6 +117,7 @@ class MailHandlerTest < Test::Unit::TestCase
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 !issue.description.match(/^searchable field:/i)
end
def test_add_issue_with_cc