Project

General

Profile

Defect #5698 ยป 5698.diff

Jan from Planio www.plan.io, 2010-06-20 16:01

View differences:

app/models/mail_handler.rb
134 134
    if status && issue.new_statuses_allowed_to(user).include?(status)
135 135
      issue.status = status
136 136
    end
137
    issue.subject = email.subject.chomp
137
    issue.subject = email.subject.chomp[0,255]
138 138
    if issue.subject.blank?
139 139
      issue.subject = '(no subject)'
140 140
    end
test/fixtures/mail_handler/ticket_with_long_subject.eml
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 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...
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
--- This line starts with a delimiter and should not be stripped
34

  
35
This paragraph is before delimiters.
36

  
37
BREAK
38

  
39
This paragraph is between delimiters.
40

  
41
---
42

  
43
This paragraph is after the delimiter so it shouldn't appear.
44

  
45
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque 
46
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem. 
47
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et, 
48
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed, 
49
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo 
50
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
51

  
52
Project: onlinestore
53
Status: Resolved
54
due date: 2010-12-31
55
Start Date:2010-01-01
56
Assigned to: John Smith
57

  
test/unit/mail_handler_test.rb
349 349
      end
350 350
    end
351 351
  end
352
  
353
  def test_email_with_long_subject_line
354
    issue = submit_email('ticket_with_long_subject.eml')
355
    assert issue.is_a?(Issue)
356
    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]
357
  end
352 358

  
353 359
  private
354 360
  
    (1-1/1)