@@ -1,263 +1,268 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
|
19 | |||
20 | class MailHandlerTest < ActiveSupport::TestCase |
|
20 | class MailHandlerTest < ActiveSupport::TestCase | |
21 | fixtures :users, :projects, |
|
21 | fixtures :users, :projects, | |
22 | :enabled_modules, |
|
22 | :enabled_modules, | |
23 | :roles, |
|
23 | :roles, | |
24 | :members, |
|
24 | :members, | |
25 | :member_roles, |
|
25 | :member_roles, | |
26 | :issues, |
|
26 | :issues, | |
27 | :issue_statuses, |
|
27 | :issue_statuses, | |
28 | :workflows, |
|
28 | :workflows, | |
29 | :trackers, |
|
29 | :trackers, | |
30 | :projects_trackers, |
|
30 | :projects_trackers, | |
31 | :enumerations, |
|
31 | :enumerations, | |
32 | :issue_categories, |
|
32 | :issue_categories, | |
33 | :custom_fields, |
|
33 | :custom_fields, | |
34 | :custom_fields_trackers, |
|
34 | :custom_fields_trackers, | |
35 | :boards, |
|
35 | :boards, | |
36 | :messages |
|
36 | :messages | |
37 |
|
37 | |||
38 | FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler' |
|
38 | FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler' | |
39 |
|
39 | |||
40 | def setup |
|
40 | def setup | |
41 | ActionMailer::Base.deliveries.clear |
|
41 | ActionMailer::Base.deliveries.clear | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def test_add_issue |
|
44 | def test_add_issue | |
|
45 | ActionMailer::Base.deliveries.clear | |||
45 | # This email contains: 'Project: onlinestore' |
|
46 | # This email contains: 'Project: onlinestore' | |
46 | issue = submit_email('ticket_on_given_project.eml') |
|
47 | issue = submit_email('ticket_on_given_project.eml') | |
47 | assert issue.is_a?(Issue) |
|
48 | assert issue.is_a?(Issue) | |
48 | assert !issue.new_record? |
|
49 | assert !issue.new_record? | |
49 | issue.reload |
|
50 | issue.reload | |
50 | assert_equal 'New ticket on a given project', issue.subject |
|
51 | assert_equal 'New ticket on a given project', issue.subject | |
51 | assert_equal User.find_by_login('jsmith'), issue.author |
|
52 | assert_equal User.find_by_login('jsmith'), issue.author | |
52 | assert_equal Project.find(2), issue.project |
|
53 | assert_equal Project.find(2), issue.project | |
53 | assert_equal IssueStatus.find_by_name('Resolved'), issue.status |
|
54 | assert_equal IssueStatus.find_by_name('Resolved'), issue.status | |
54 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
55 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |
55 | # keywords should be removed from the email body |
|
56 | # keywords should be removed from the email body | |
56 | assert !issue.description.match(/^Project:/i) |
|
57 | assert !issue.description.match(/^Project:/i) | |
57 | assert !issue.description.match(/^Status:/i) |
|
58 | assert !issue.description.match(/^Status:/i) | |
|
59 | # Email notification should be sent | |||
|
60 | mail = ActionMailer::Base.deliveries.last | |||
|
61 | assert_not_nil mail | |||
|
62 | assert mail.subject.include?('New ticket on a given project') | |||
58 | end |
|
63 | end | |
59 |
|
64 | |||
60 | def test_add_issue_with_status |
|
65 | def test_add_issue_with_status | |
61 | # This email contains: 'Project: onlinestore' and 'Status: Resolved' |
|
66 | # This email contains: 'Project: onlinestore' and 'Status: Resolved' | |
62 | issue = submit_email('ticket_on_given_project.eml') |
|
67 | issue = submit_email('ticket_on_given_project.eml') | |
63 | assert issue.is_a?(Issue) |
|
68 | assert issue.is_a?(Issue) | |
64 | assert !issue.new_record? |
|
69 | assert !issue.new_record? | |
65 | issue.reload |
|
70 | issue.reload | |
66 | assert_equal Project.find(2), issue.project |
|
71 | assert_equal Project.find(2), issue.project | |
67 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status |
|
72 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status | |
68 | end |
|
73 | end | |
69 |
|
74 | |||
70 | def test_add_issue_with_attributes_override |
|
75 | def test_add_issue_with_attributes_override | |
71 | issue = submit_email('ticket_with_attributes.eml', :allow_override => 'tracker,category,priority') |
|
76 | issue = submit_email('ticket_with_attributes.eml', :allow_override => 'tracker,category,priority') | |
72 | assert issue.is_a?(Issue) |
|
77 | assert issue.is_a?(Issue) | |
73 | assert !issue.new_record? |
|
78 | assert !issue.new_record? | |
74 | issue.reload |
|
79 | issue.reload | |
75 | assert_equal 'New ticket on a given project', issue.subject |
|
80 | assert_equal 'New ticket on a given project', issue.subject | |
76 | assert_equal User.find_by_login('jsmith'), issue.author |
|
81 | assert_equal User.find_by_login('jsmith'), issue.author | |
77 | assert_equal Project.find(2), issue.project |
|
82 | assert_equal Project.find(2), issue.project | |
78 | assert_equal 'Feature request', issue.tracker.to_s |
|
83 | assert_equal 'Feature request', issue.tracker.to_s | |
79 | assert_equal 'Stock management', issue.category.to_s |
|
84 | assert_equal 'Stock management', issue.category.to_s | |
80 | assert_equal 'Urgent', issue.priority.to_s |
|
85 | assert_equal 'Urgent', issue.priority.to_s | |
81 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
86 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |
82 | end |
|
87 | end | |
83 |
|
88 | |||
84 | def test_add_issue_with_partial_attributes_override |
|
89 | def test_add_issue_with_partial_attributes_override | |
85 | issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker']) |
|
90 | issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker']) | |
86 | assert issue.is_a?(Issue) |
|
91 | assert issue.is_a?(Issue) | |
87 | assert !issue.new_record? |
|
92 | assert !issue.new_record? | |
88 | issue.reload |
|
93 | issue.reload | |
89 | assert_equal 'New ticket on a given project', issue.subject |
|
94 | assert_equal 'New ticket on a given project', issue.subject | |
90 | assert_equal User.find_by_login('jsmith'), issue.author |
|
95 | assert_equal User.find_by_login('jsmith'), issue.author | |
91 | assert_equal Project.find(2), issue.project |
|
96 | assert_equal Project.find(2), issue.project | |
92 | assert_equal 'Feature request', issue.tracker.to_s |
|
97 | assert_equal 'Feature request', issue.tracker.to_s | |
93 | assert_nil issue.category |
|
98 | assert_nil issue.category | |
94 | assert_equal 'High', issue.priority.to_s |
|
99 | assert_equal 'High', issue.priority.to_s | |
95 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
100 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |
96 | end |
|
101 | end | |
97 |
|
102 | |||
98 | def test_add_issue_with_spaces_between_attribute_and_separator |
|
103 | 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') |
|
104 | issue = submit_email('ticket_with_spaces_between_attribute_and_separator.eml', :allow_override => 'tracker,category,priority') | |
100 | assert issue.is_a?(Issue) |
|
105 | assert issue.is_a?(Issue) | |
101 | assert !issue.new_record? |
|
106 | assert !issue.new_record? | |
102 | issue.reload |
|
107 | issue.reload | |
103 | assert_equal 'New ticket on a given project', issue.subject |
|
108 | assert_equal 'New ticket on a given project', issue.subject | |
104 | assert_equal User.find_by_login('jsmith'), issue.author |
|
109 | assert_equal User.find_by_login('jsmith'), issue.author | |
105 | assert_equal Project.find(2), issue.project |
|
110 | assert_equal Project.find(2), issue.project | |
106 | assert_equal 'Feature request', issue.tracker.to_s |
|
111 | assert_equal 'Feature request', issue.tracker.to_s | |
107 | assert_equal 'Stock management', issue.category.to_s |
|
112 | assert_equal 'Stock management', issue.category.to_s | |
108 | assert_equal 'Urgent', issue.priority.to_s |
|
113 | assert_equal 'Urgent', issue.priority.to_s | |
109 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') |
|
114 | assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') | |
110 | end |
|
115 | end | |
111 |
|
116 | |||
112 |
|
117 | |||
113 | def test_add_issue_with_attachment_to_specific_project |
|
118 | def test_add_issue_with_attachment_to_specific_project | |
114 | issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'}) |
|
119 | issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'}) | |
115 | assert issue.is_a?(Issue) |
|
120 | assert issue.is_a?(Issue) | |
116 | assert !issue.new_record? |
|
121 | assert !issue.new_record? | |
117 | issue.reload |
|
122 | issue.reload | |
118 | assert_equal 'Ticket created by email with attachment', issue.subject |
|
123 | assert_equal 'Ticket created by email with attachment', issue.subject | |
119 | assert_equal User.find_by_login('jsmith'), issue.author |
|
124 | assert_equal User.find_by_login('jsmith'), issue.author | |
120 | assert_equal Project.find(2), issue.project |
|
125 | assert_equal Project.find(2), issue.project | |
121 | assert_equal 'This is a new ticket with attachments', issue.description |
|
126 | assert_equal 'This is a new ticket with attachments', issue.description | |
122 | # Attachment properties |
|
127 | # Attachment properties | |
123 | assert_equal 1, issue.attachments.size |
|
128 | assert_equal 1, issue.attachments.size | |
124 | assert_equal 'Paella.jpg', issue.attachments.first.filename |
|
129 | assert_equal 'Paella.jpg', issue.attachments.first.filename | |
125 | assert_equal 'image/jpeg', issue.attachments.first.content_type |
|
130 | assert_equal 'image/jpeg', issue.attachments.first.content_type | |
126 | assert_equal 10790, issue.attachments.first.filesize |
|
131 | assert_equal 10790, issue.attachments.first.filesize | |
127 | end |
|
132 | end | |
128 |
|
133 | |||
129 | def test_add_issue_with_custom_fields |
|
134 | def test_add_issue_with_custom_fields | |
130 | issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'onlinestore'}) |
|
135 | issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'onlinestore'}) | |
131 | assert issue.is_a?(Issue) |
|
136 | assert issue.is_a?(Issue) | |
132 | assert !issue.new_record? |
|
137 | assert !issue.new_record? | |
133 | issue.reload |
|
138 | issue.reload | |
134 | assert_equal 'New ticket with custom field values', issue.subject |
|
139 | assert_equal 'New ticket with custom field values', issue.subject | |
135 | assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value |
|
140 | assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value | |
136 | assert !issue.description.match(/^searchable field:/i) |
|
141 | assert !issue.description.match(/^searchable field:/i) | |
137 | end |
|
142 | end | |
138 |
|
143 | |||
139 | def test_add_issue_with_cc |
|
144 | def test_add_issue_with_cc | |
140 | issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) |
|
145 | issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) | |
141 | assert issue.is_a?(Issue) |
|
146 | assert issue.is_a?(Issue) | |
142 | assert !issue.new_record? |
|
147 | assert !issue.new_record? | |
143 | issue.reload |
|
148 | issue.reload | |
144 | assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo')) |
|
149 | assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo')) | |
145 | assert_equal 1, issue.watchers.size |
|
150 | assert_equal 1, issue.watchers.size | |
146 | end |
|
151 | end | |
147 |
|
152 | |||
148 | def test_add_issue_by_unknown_user |
|
153 | def test_add_issue_by_unknown_user | |
149 | assert_no_difference 'User.count' do |
|
154 | assert_no_difference 'User.count' do | |
150 | assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}) |
|
155 | assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}) | |
151 | end |
|
156 | end | |
152 | end |
|
157 | end | |
153 |
|
158 | |||
154 | def test_add_issue_by_anonymous_user |
|
159 | def test_add_issue_by_anonymous_user | |
155 | Role.anonymous.add_permission!(:add_issues) |
|
160 | Role.anonymous.add_permission!(:add_issues) | |
156 | assert_no_difference 'User.count' do |
|
161 | assert_no_difference 'User.count' do | |
157 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept') |
|
162 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept') | |
158 | assert issue.is_a?(Issue) |
|
163 | assert issue.is_a?(Issue) | |
159 | assert issue.author.anonymous? |
|
164 | assert issue.author.anonymous? | |
160 | end |
|
165 | end | |
161 | end |
|
166 | end | |
162 |
|
167 | |||
163 | def test_add_issue_by_created_user |
|
168 | def test_add_issue_by_created_user | |
164 | Setting.default_language = 'en' |
|
169 | Setting.default_language = 'en' | |
165 | assert_difference 'User.count' do |
|
170 | assert_difference 'User.count' do | |
166 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') |
|
171 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') | |
167 | assert issue.is_a?(Issue) |
|
172 | assert issue.is_a?(Issue) | |
168 | assert issue.author.active? |
|
173 | assert issue.author.active? | |
169 | assert_equal 'john.doe@somenet.foo', issue.author.mail |
|
174 | assert_equal 'john.doe@somenet.foo', issue.author.mail | |
170 | assert_equal 'John', issue.author.firstname |
|
175 | assert_equal 'John', issue.author.firstname | |
171 | assert_equal 'Doe', issue.author.lastname |
|
176 | assert_equal 'Doe', issue.author.lastname | |
172 |
|
177 | |||
173 | # account information |
|
178 | # account information | |
174 | email = ActionMailer::Base.deliveries.first |
|
179 | email = ActionMailer::Base.deliveries.first | |
175 | assert_not_nil email |
|
180 | assert_not_nil email | |
176 | assert email.subject.include?('account activation') |
|
181 | assert email.subject.include?('account activation') | |
177 | login = email.body.match(/\* Login: (.*)$/)[1] |
|
182 | login = email.body.match(/\* Login: (.*)$/)[1] | |
178 | password = email.body.match(/\* Password: (.*)$/)[1] |
|
183 | password = email.body.match(/\* Password: (.*)$/)[1] | |
179 | assert_equal issue.author, User.try_to_login(login, password) |
|
184 | assert_equal issue.author, User.try_to_login(login, password) | |
180 | end |
|
185 | end | |
181 | end |
|
186 | end | |
182 |
|
187 | |||
183 | def test_add_issue_without_from_header |
|
188 | def test_add_issue_without_from_header | |
184 | Role.anonymous.add_permission!(:add_issues) |
|
189 | Role.anonymous.add_permission!(:add_issues) | |
185 | assert_equal false, submit_email('ticket_without_from_header.eml') |
|
190 | assert_equal false, submit_email('ticket_without_from_header.eml') | |
186 | end |
|
191 | end | |
187 |
|
192 | |||
188 | def test_should_ignore_emails_from_emission_address |
|
193 | def test_should_ignore_emails_from_emission_address | |
189 | Role.anonymous.add_permission!(:add_issues) |
|
194 | Role.anonymous.add_permission!(:add_issues) | |
190 | assert_no_difference 'User.count' do |
|
195 | assert_no_difference 'User.count' do | |
191 | assert_equal false, submit_email('ticket_from_emission_address.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') |
|
196 | assert_equal false, submit_email('ticket_from_emission_address.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') | |
192 | end |
|
197 | end | |
193 | end |
|
198 | end | |
194 |
|
199 | |||
195 | def test_add_issue_should_send_email_notification |
|
200 | def test_add_issue_should_send_email_notification | |
196 | ActionMailer::Base.deliveries.clear |
|
201 | ActionMailer::Base.deliveries.clear | |
197 | # This email contains: 'Project: onlinestore' |
|
202 | # This email contains: 'Project: onlinestore' | |
198 | issue = submit_email('ticket_on_given_project.eml') |
|
203 | issue = submit_email('ticket_on_given_project.eml') | |
199 | assert issue.is_a?(Issue) |
|
204 | assert issue.is_a?(Issue) | |
200 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
205 | assert_equal 1, ActionMailer::Base.deliveries.size | |
201 | end |
|
206 | end | |
202 |
|
207 | |||
203 | def test_add_issue_note |
|
208 | def test_add_issue_note | |
204 | journal = submit_email('ticket_reply.eml') |
|
209 | journal = submit_email('ticket_reply.eml') | |
205 | assert journal.is_a?(Journal) |
|
210 | assert journal.is_a?(Journal) | |
206 | assert_equal User.find_by_login('jsmith'), journal.user |
|
211 | assert_equal User.find_by_login('jsmith'), journal.user | |
207 | assert_equal Issue.find(2), journal.journalized |
|
212 | assert_equal Issue.find(2), journal.journalized | |
208 | assert_match /This is reply/, journal.notes |
|
213 | assert_match /This is reply/, journal.notes | |
209 | end |
|
214 | end | |
210 |
|
215 | |||
211 | def test_add_issue_note_with_status_change |
|
216 | def test_add_issue_note_with_status_change | |
212 | # This email contains: 'Status: Resolved' |
|
217 | # This email contains: 'Status: Resolved' | |
213 | journal = submit_email('ticket_reply_with_status.eml') |
|
218 | journal = submit_email('ticket_reply_with_status.eml') | |
214 | assert journal.is_a?(Journal) |
|
219 | assert journal.is_a?(Journal) | |
215 | issue = Issue.find(journal.issue.id) |
|
220 | issue = Issue.find(journal.issue.id) | |
216 | assert_equal User.find_by_login('jsmith'), journal.user |
|
221 | assert_equal User.find_by_login('jsmith'), journal.user | |
217 | assert_equal Issue.find(2), journal.journalized |
|
222 | assert_equal Issue.find(2), journal.journalized | |
218 | assert_match /This is reply/, journal.notes |
|
223 | assert_match /This is reply/, journal.notes | |
219 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status |
|
224 | assert_equal IssueStatus.find_by_name("Resolved"), issue.status | |
220 | end |
|
225 | end | |
221 |
|
226 | |||
222 | def test_add_issue_note_should_send_email_notification |
|
227 | def test_add_issue_note_should_send_email_notification | |
223 | ActionMailer::Base.deliveries.clear |
|
228 | ActionMailer::Base.deliveries.clear | |
224 | journal = submit_email('ticket_reply.eml') |
|
229 | journal = submit_email('ticket_reply.eml') | |
225 | assert journal.is_a?(Journal) |
|
230 | assert journal.is_a?(Journal) | |
226 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
231 | assert_equal 1, ActionMailer::Base.deliveries.size | |
227 | end |
|
232 | end | |
228 |
|
233 | |||
229 | def test_reply_to_a_message |
|
234 | def test_reply_to_a_message | |
230 | m = submit_email('message_reply.eml') |
|
235 | m = submit_email('message_reply.eml') | |
231 | assert m.is_a?(Message) |
|
236 | assert m.is_a?(Message) | |
232 | assert !m.new_record? |
|
237 | assert !m.new_record? | |
233 | m.reload |
|
238 | m.reload | |
234 | assert_equal 'Reply via email', m.subject |
|
239 | assert_equal 'Reply via email', m.subject | |
235 | # The email replies to message #2 which is part of the thread of message #1 |
|
240 | # The email replies to message #2 which is part of the thread of message #1 | |
236 | assert_equal Message.find(1), m.parent |
|
241 | assert_equal Message.find(1), m.parent | |
237 | end |
|
242 | end | |
238 |
|
243 | |||
239 | def test_reply_to_a_message_by_subject |
|
244 | def test_reply_to_a_message_by_subject | |
240 | m = submit_email('message_reply_by_subject.eml') |
|
245 | m = submit_email('message_reply_by_subject.eml') | |
241 | assert m.is_a?(Message) |
|
246 | assert m.is_a?(Message) | |
242 | assert !m.new_record? |
|
247 | assert !m.new_record? | |
243 | m.reload |
|
248 | m.reload | |
244 | assert_equal 'Reply to the first post', m.subject |
|
249 | assert_equal 'Reply to the first post', m.subject | |
245 | assert_equal Message.find(1), m.parent |
|
250 | assert_equal Message.find(1), m.parent | |
246 | end |
|
251 | end | |
247 |
|
252 | |||
248 | def test_should_strip_tags_of_html_only_emails |
|
253 | def test_should_strip_tags_of_html_only_emails | |
249 | issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'}) |
|
254 | issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'}) | |
250 | assert issue.is_a?(Issue) |
|
255 | assert issue.is_a?(Issue) | |
251 | assert !issue.new_record? |
|
256 | assert !issue.new_record? | |
252 | issue.reload |
|
257 | issue.reload | |
253 | assert_equal 'HTML email', issue.subject |
|
258 | assert_equal 'HTML email', issue.subject | |
254 | assert_equal 'This is a html-only email.', issue.description |
|
259 | assert_equal 'This is a html-only email.', issue.description | |
255 | end |
|
260 | end | |
256 |
|
261 | |||
257 | private |
|
262 | private | |
258 |
|
263 | |||
259 | def submit_email(filename, options={}) |
|
264 | def submit_email(filename, options={}) | |
260 | raw = IO.read(File.join(FIXTURES_PATH, filename)) |
|
265 | raw = IO.read(File.join(FIXTURES_PATH, filename)) | |
261 | MailHandler.receive(raw, options) |
|
266 | MailHandler.receive(raw, options) | |
262 | end |
|
267 | end | |
263 | end |
|
268 | end |
General Comments 0
You need to be logged in to leave comments.
Login now