Project

General

Profile

Patch #3731 ยป patch_incoming_mail_parsing.diff

Thomas Recloux, 2009-08-12 15:15

View differences:

test/unit/mail_handler_test.rb (working copy)
80 80
    assert_equal 'Urgent', issue.priority.to_s
81 81
    assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
82 82
  end
83
  
83

  
84 84
  def test_add_issue_with_partial_attributes_override
85 85
    issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker'])
86 86
    assert issue.is_a?(Issue)
......
95 95
    assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
96 96
  end
97 97
  
98
  def test_add_issue_with_spaces_between_attribute_and_separator
99
    issue = submit_email('ticket_with_spaces_between_attribute_and_separator.eml', :allow_override => 'tracker,category,priority')
100
    assert issue.is_a?(Issue)
101
    assert !issue.new_record?
102
    issue.reload
103
    assert_equal 'New ticket on a given project', issue.subject
104
    assert_equal User.find_by_login('jsmith'), issue.author
105
    assert_equal Project.find(2), issue.project
106
    assert_equal 'Feature request', issue.tracker.to_s
107
    assert_equal 'Stock management', issue.category.to_s
108
    assert_equal 'Urgent', issue.priority.to_s
109
    assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
110
  end
111

  
112
  
98 113
  def test_add_issue_with_attachment_to_specific_project
99 114
    issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
100 115
    assert issue.is_a?(Issue)
test/fixtures/mail_handler/ticket_with_spaces_between_attribute_and_separator.eml (revision 0)
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. Maecenas imperdiet 
22
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus 
23
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti 
24
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In 
25
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras 
26
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum 
27
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus 
28
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique 
29
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et 
30
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse 
31
platea dictumst.
32

  
33
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque 
34
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem. 
35
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et, 
36
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed, 
37
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo 
38
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
39

  
40
Project : onlinestore
41
Tracker: Feature request
42
category : Stock management
43
priority: Urgent
app/models/mail_handler.rb (working copy)
224 224
      @keywords[attr]
225 225
    else
226 226
      @keywords[attr] = begin
227
        if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}:[ \t]*(.+)\s*$/i, '')
227
        if (options[:override] || @@handler_options[:allow_override].include?(attr.to_s)) && plain_text_body.gsub!(/^#{attr}[ \t]*:[ \t]*(.+)\s*$/i, '')
228 228
          $1.strip
229 229
        elsif !@@handler_options[:issue][attr].blank?
230 230
          @@handler_options[:issue][attr]
    (1-1/1)