##// END OF EJS Templates
Strip keywords from received email body (#2436)....
Jean-Philippe Lang -
r2365:2d3b3cee156c
parent child
Show More
@@ -203,10 +203,17 class MailHandler < ActionMailer::Base
203 end
203 end
204
204
205 def get_keyword(attr, options={})
205 def get_keyword(attr, options={})
206 if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body =~ /^#{attr}:[ \t]*(.+)$/i
206 @keywords ||= {}
207 $1.strip
207 if @keywords.has_key?(attr)
208 elsif !@@handler_options[:issue][attr].blank?
208 @keywords[attr]
209 @@handler_options[:issue][attr]
209 else
210 @keywords[attr] = begin
211 if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '')
212 $1.strip
213 elsif !@@handler_options[:issue][attr].blank?
214 @@handler_options[:issue][attr]
215 end
216 end
210 end
217 end
211 end
218 end
212
219
@@ -49,7 +49,11 class MailHandlerTest < Test::Unit::TestCase
49 assert_equal 'New ticket on a given project', issue.subject
49 assert_equal 'New ticket on a given project', issue.subject
50 assert_equal User.find_by_login('jsmith'), issue.author
50 assert_equal User.find_by_login('jsmith'), issue.author
51 assert_equal Project.find(2), issue.project
51 assert_equal Project.find(2), issue.project
52 assert_equal IssueStatus.find_by_name('Resolved'), issue.status
52 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
53 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
54 # keywords should be removed from the email body
55 assert !issue.description.match(/^Project:/i)
56 assert !issue.description.match(/^Status:/i)
53 end
57 end
54
58
55 def test_add_issue_with_status
59 def test_add_issue_with_status
@@ -113,6 +117,7 class MailHandlerTest < Test::Unit::TestCase
113 issue.reload
117 issue.reload
114 assert_equal 'New ticket with custom field values', issue.subject
118 assert_equal 'New ticket with custom field values', issue.subject
115 assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
119 assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
120 assert !issue.description.match(/^searchable field:/i)
116 end
121 end
117
122
118 def test_add_issue_with_cc
123 def test_add_issue_with_cc
General Comments 0
You need to be logged in to leave comments. Login now