##// END OF EJS Templates
Ignore email keywords after truncation line (#8758)....
Jean-Philippe Lang -
r13050:8ae41b4846fc
parent child
Show More
@@ -0,0 +1,25
1 Return-Path: <JSmith@somenet.foo>
2 Received: from osiris ([127.0.0.1])
3 by OSIRIS
4 with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
5 Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
6 From: "John Smith" <JSmith@somenet.foo>
7 To: <redmine@somenet.foo>
8 Subject: New ticket on a given project
9 Date: Sun, 22 Jun 2008 12:28:07 +0200
10 MIME-Version: 1.0
11 Content-Type: text/plain;
12 format=flowed;
13 charset="iso-8859-1";
14 reply-type=original
15 Content-Transfer-Encoding: 7bit
16 X-Priority: 3
17 X-MSMail-Priority: Normal
18 X-Mailer: Microsoft Outlook Express 6.00.2900.2869
19 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
20
21 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
22
23 Project: ecookbook
24 Priority: High
25 Priority: Low
@@ -0,0 +1,27
1 Return-Path: <JSmith@somenet.foo>
2 Received: from osiris ([127.0.0.1])
3 by OSIRIS
4 with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
5 Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
6 From: "John Smith" <JSmith@somenet.foo>
7 To: <redmine@somenet.foo>
8 Subject: New ticket on a given project
9 Date: Sun, 22 Jun 2008 12:28:07 +0200
10 MIME-Version: 1.0
11 Content-Type: text/plain;
12 format=flowed;
13 charset="iso-8859-1";
14 reply-type=original
15 Content-Transfer-Encoding: 7bit
16 X-Priority: 3
17 X-MSMail-Priority: Normal
18 X-Mailer: Microsoft Outlook Express 6.00.2900.2869
19 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
20
21 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
22
23 Project: ecookbook
24
25 == DELIMITER ==
26
27 Priority: High
@@ -319,7 +319,7 class MailHandler < ActionMailer::Base
319 319 else
320 320 @keywords[attr] = begin
321 321 if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) &&
322 (v = extract_keyword!(plain_text_body, attr, options[:format]))
322 (v = extract_keyword!(cleaned_up_text_body, attr, options[:format]))
323 323 v
324 324 elsif !@@handler_options[:issue][attr].blank?
325 325 @@handler_options[:issue][attr]
@@ -347,7 +347,7 class MailHandler < ActionMailer::Base
347 347 regexp = /^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i
348 348 if m = text.match(regexp)
349 349 keyword = m[2].strip
350 text.gsub!(regexp, '')
350 text.sub!(regexp, '')
351 351 end
352 352 keyword
353 353 end
@@ -436,7 +436,7 class MailHandler < ActionMailer::Base
436 436 end
437 437
438 438 def cleaned_up_text_body
439 cleanup_body(plain_text_body)
439 @cleaned_up_text_body ||= cleanup_body(plain_text_body)
440 440 end
441 441
442 442 def cleaned_up_subject
@@ -30,6 +30,15 sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et
30 30 malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
31 31 platea dictumst.
32 32
33 Project: onlinestore
34 Status: Resolved
35 due date: 2010-12-31
36 Start Date:2010-01-01
37 Assigned to: John Smith
38 fixed version: alpha
39 estimated hours: 2.5
40 done ratio: 30
41
33 42 --- This line starts with a delimiter and should not be stripped
34 43
35 44 This paragraph is before delimiters.
@@ -49,12 +58,3 dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
49 58 massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
50 59 pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
51 60
52 Project: onlinestore
53 Status: Resolved
54 due date: 2010-12-31
55 Start Date:2010-01-01
56 Assigned to: John Smith
57 fixed version: alpha
58 estimated hours: 2.5
59 done ratio: 30
60
@@ -856,6 +856,20 class MailHandlerTest < ActiveSupport::TestCase
856 856 assert_equal issue.subject, 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[0,255]
857 857 end
858 858
859 def test_first_keyword_should_be_matched
860 issue = submit_email('ticket_with_duplicate_keyword.eml', :allow_override => 'priority')
861 assert issue.is_a?(Issue)
862 assert_equal 'High', issue.priority.name
863 end
864
865 def test_keyword_after_delimiter_should_be_ignored
866 with_settings :mail_handler_body_delimiters => "== DELIMITER ==" do
867 issue = submit_email('ticket_with_keyword_after_delimiter.eml', :allow_override => 'priority')
868 assert issue.is_a?(Issue)
869 assert_equal 'Normal', issue.priority.name
870 end
871 end
872
859 873 def test_new_user_from_attributes_should_return_valid_user
860 874 to_test = {
861 875 # [address, name] => [login, firstname, lastname]
General Comments 0
You need to be logged in to leave comments. Login now