##// END OF EJS Templates
add test of quoted printable UTF-8 mail reviving (#14675)...
Toshi MARUYAMA -
r12626:14c02f50cc44
parent child
Show More
@@ -0,0 +1,19
1 Date: Tue, 13 Aug 2013 10:56:04 +0700
2 From: John Smith <JSmith@somenet.foo>
3 Content-Type: multipart/alternative; boundary=001a11c260fa53f8dc04e3cc380b
4 Subject: issue 14675
5 To: redmine@somenet.foo
6
7 --001a11c260fa53f8dc04e3cc380b
8 Content-Type: text/plain; charset=UTF-8
9 Content-Transfer-Encoding: quoted-printable
10
11 Freundliche Gr=C3=BCsse
12
13 --001a11c260fa53f8dc04e3cc380b
14 Content-Type: text/html; charset=UTF-8
15 Content-Transfer-Encoding: quoted-printable
16
17 <div dir=3D"ltr">Freundliche Gr=C3=BCsse<br></div>
18
19 --001a11c260fa53f8dc04e3cc380b--
@@ -1,887 +1,898
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2014 Jean-Philippe Lang
4 # Copyright (C) 2006-2014 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 require File.expand_path('../../test_helper', __FILE__)
20 require File.expand_path('../../test_helper', __FILE__)
21
21
22 class MailHandlerTest < ActiveSupport::TestCase
22 class MailHandlerTest < ActiveSupport::TestCase
23 fixtures :users, :projects, :enabled_modules, :roles,
23 fixtures :users, :projects, :enabled_modules, :roles,
24 :members, :member_roles, :users,
24 :members, :member_roles, :users,
25 :issues, :issue_statuses,
25 :issues, :issue_statuses,
26 :workflows, :trackers, :projects_trackers,
26 :workflows, :trackers, :projects_trackers,
27 :versions, :enumerations, :issue_categories,
27 :versions, :enumerations, :issue_categories,
28 :custom_fields, :custom_fields_trackers, :custom_fields_projects,
28 :custom_fields, :custom_fields_trackers, :custom_fields_projects,
29 :boards, :messages
29 :boards, :messages
30
30
31 FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
31 FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
32
32
33 def setup
33 def setup
34 ActionMailer::Base.deliveries.clear
34 ActionMailer::Base.deliveries.clear
35 Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
35 Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
36 end
36 end
37
37
38 def teardown
38 def teardown
39 Setting.clear_cache
39 Setting.clear_cache
40 end
40 end
41
41
42 def test_add_issue
42 def test_add_issue
43 ActionMailer::Base.deliveries.clear
43 ActionMailer::Base.deliveries.clear
44 lft1 = new_issue_lft
44 lft1 = new_issue_lft
45 # This email contains: 'Project: onlinestore'
45 # This email contains: 'Project: onlinestore'
46 issue = submit_email('ticket_on_given_project.eml')
46 issue = submit_email('ticket_on_given_project.eml')
47 assert issue.is_a?(Issue)
47 assert issue.is_a?(Issue)
48 assert !issue.new_record?
48 assert !issue.new_record?
49 issue.reload
49 issue.reload
50 assert_equal Project.find(2), issue.project
50 assert_equal Project.find(2), issue.project
51 assert_equal issue.project.trackers.first, issue.tracker
51 assert_equal issue.project.trackers.first, issue.tracker
52 assert_equal 'New ticket on a given project', issue.subject
52 assert_equal 'New ticket on a given project', issue.subject
53 assert_equal User.find_by_login('jsmith'), issue.author
53 assert_equal User.find_by_login('jsmith'), issue.author
54 assert_equal IssueStatus.find_by_name('Resolved'), issue.status
54 assert_equal IssueStatus.find_by_name('Resolved'), issue.status
55 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.')
56 assert_equal '2010-01-01', issue.start_date.to_s
56 assert_equal '2010-01-01', issue.start_date.to_s
57 assert_equal '2010-12-31', issue.due_date.to_s
57 assert_equal '2010-12-31', issue.due_date.to_s
58 assert_equal User.find_by_login('jsmith'), issue.assigned_to
58 assert_equal User.find_by_login('jsmith'), issue.assigned_to
59 assert_equal Version.find_by_name('Alpha'), issue.fixed_version
59 assert_equal Version.find_by_name('Alpha'), issue.fixed_version
60 assert_equal 2.5, issue.estimated_hours
60 assert_equal 2.5, issue.estimated_hours
61 assert_equal 30, issue.done_ratio
61 assert_equal 30, issue.done_ratio
62 assert_equal [issue.id, lft1, lft1 + 1], [issue.root_id, issue.lft, issue.rgt]
62 assert_equal [issue.id, lft1, lft1 + 1], [issue.root_id, issue.lft, issue.rgt]
63 # keywords should be removed from the email body
63 # keywords should be removed from the email body
64 assert !issue.description.match(/^Project:/i)
64 assert !issue.description.match(/^Project:/i)
65 assert !issue.description.match(/^Status:/i)
65 assert !issue.description.match(/^Status:/i)
66 assert !issue.description.match(/^Start Date:/i)
66 assert !issue.description.match(/^Start Date:/i)
67 # Email notification should be sent
67 # Email notification should be sent
68 mail = ActionMailer::Base.deliveries.last
68 mail = ActionMailer::Base.deliveries.last
69 assert_not_nil mail
69 assert_not_nil mail
70 assert mail.subject.include?('New ticket on a given project')
70 assert mail.subject.include?('New ticket on a given project')
71 end
71 end
72
72
73 def test_add_issue_with_default_tracker
73 def test_add_issue_with_default_tracker
74 # This email contains: 'Project: onlinestore'
74 # This email contains: 'Project: onlinestore'
75 issue = submit_email(
75 issue = submit_email(
76 'ticket_on_given_project.eml',
76 'ticket_on_given_project.eml',
77 :issue => {:tracker => 'Support request'}
77 :issue => {:tracker => 'Support request'}
78 )
78 )
79 assert issue.is_a?(Issue)
79 assert issue.is_a?(Issue)
80 assert !issue.new_record?
80 assert !issue.new_record?
81 issue.reload
81 issue.reload
82 assert_equal 'Support request', issue.tracker.name
82 assert_equal 'Support request', issue.tracker.name
83 end
83 end
84
84
85 def test_add_issue_with_status
85 def test_add_issue_with_status
86 # This email contains: 'Project: onlinestore' and 'Status: Resolved'
86 # This email contains: 'Project: onlinestore' and 'Status: Resolved'
87 issue = submit_email('ticket_on_given_project.eml')
87 issue = submit_email('ticket_on_given_project.eml')
88 assert issue.is_a?(Issue)
88 assert issue.is_a?(Issue)
89 assert !issue.new_record?
89 assert !issue.new_record?
90 issue.reload
90 issue.reload
91 assert_equal Project.find(2), issue.project
91 assert_equal Project.find(2), issue.project
92 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
92 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
93 end
93 end
94
94
95 def test_add_issue_with_attributes_override
95 def test_add_issue_with_attributes_override
96 issue = submit_email(
96 issue = submit_email(
97 'ticket_with_attributes.eml',
97 'ticket_with_attributes.eml',
98 :allow_override => 'tracker,category,priority'
98 :allow_override => 'tracker,category,priority'
99 )
99 )
100 assert issue.is_a?(Issue)
100 assert issue.is_a?(Issue)
101 assert !issue.new_record?
101 assert !issue.new_record?
102 issue.reload
102 issue.reload
103 assert_equal 'New ticket on a given project', issue.subject
103 assert_equal 'New ticket on a given project', issue.subject
104 assert_equal User.find_by_login('jsmith'), issue.author
104 assert_equal User.find_by_login('jsmith'), issue.author
105 assert_equal Project.find(2), issue.project
105 assert_equal Project.find(2), issue.project
106 assert_equal 'Feature request', issue.tracker.to_s
106 assert_equal 'Feature request', issue.tracker.to_s
107 assert_equal 'Stock management', issue.category.to_s
107 assert_equal 'Stock management', issue.category.to_s
108 assert_equal 'Urgent', issue.priority.to_s
108 assert_equal 'Urgent', issue.priority.to_s
109 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
109 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
110 end
110 end
111
111
112 def test_add_issue_with_group_assignment
112 def test_add_issue_with_group_assignment
113 with_settings :issue_group_assignment => '1' do
113 with_settings :issue_group_assignment => '1' do
114 issue = submit_email('ticket_on_given_project.eml') do |email|
114 issue = submit_email('ticket_on_given_project.eml') do |email|
115 email.gsub!('Assigned to: John Smith', 'Assigned to: B Team')
115 email.gsub!('Assigned to: John Smith', 'Assigned to: B Team')
116 end
116 end
117 assert issue.is_a?(Issue)
117 assert issue.is_a?(Issue)
118 assert !issue.new_record?
118 assert !issue.new_record?
119 issue.reload
119 issue.reload
120 assert_equal Group.find(11), issue.assigned_to
120 assert_equal Group.find(11), issue.assigned_to
121 end
121 end
122 end
122 end
123
123
124 def test_add_issue_with_partial_attributes_override
124 def test_add_issue_with_partial_attributes_override
125 issue = submit_email(
125 issue = submit_email(
126 'ticket_with_attributes.eml',
126 'ticket_with_attributes.eml',
127 :issue => {:priority => 'High'},
127 :issue => {:priority => 'High'},
128 :allow_override => ['tracker']
128 :allow_override => ['tracker']
129 )
129 )
130 assert issue.is_a?(Issue)
130 assert issue.is_a?(Issue)
131 assert !issue.new_record?
131 assert !issue.new_record?
132 issue.reload
132 issue.reload
133 assert_equal 'New ticket on a given project', issue.subject
133 assert_equal 'New ticket on a given project', issue.subject
134 assert_equal User.find_by_login('jsmith'), issue.author
134 assert_equal User.find_by_login('jsmith'), issue.author
135 assert_equal Project.find(2), issue.project
135 assert_equal Project.find(2), issue.project
136 assert_equal 'Feature request', issue.tracker.to_s
136 assert_equal 'Feature request', issue.tracker.to_s
137 assert_nil issue.category
137 assert_nil issue.category
138 assert_equal 'High', issue.priority.to_s
138 assert_equal 'High', issue.priority.to_s
139 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
139 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
140 end
140 end
141
141
142 def test_add_issue_with_spaces_between_attribute_and_separator
142 def test_add_issue_with_spaces_between_attribute_and_separator
143 issue = submit_email(
143 issue = submit_email(
144 'ticket_with_spaces_between_attribute_and_separator.eml',
144 'ticket_with_spaces_between_attribute_and_separator.eml',
145 :allow_override => 'tracker,category,priority'
145 :allow_override => 'tracker,category,priority'
146 )
146 )
147 assert issue.is_a?(Issue)
147 assert issue.is_a?(Issue)
148 assert !issue.new_record?
148 assert !issue.new_record?
149 issue.reload
149 issue.reload
150 assert_equal 'New ticket on a given project', issue.subject
150 assert_equal 'New ticket on a given project', issue.subject
151 assert_equal User.find_by_login('jsmith'), issue.author
151 assert_equal User.find_by_login('jsmith'), issue.author
152 assert_equal Project.find(2), issue.project
152 assert_equal Project.find(2), issue.project
153 assert_equal 'Feature request', issue.tracker.to_s
153 assert_equal 'Feature request', issue.tracker.to_s
154 assert_equal 'Stock management', issue.category.to_s
154 assert_equal 'Stock management', issue.category.to_s
155 assert_equal 'Urgent', issue.priority.to_s
155 assert_equal 'Urgent', issue.priority.to_s
156 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
156 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
157 end
157 end
158
158
159 def test_add_issue_with_attachment_to_specific_project
159 def test_add_issue_with_attachment_to_specific_project
160 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
160 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
161 assert issue.is_a?(Issue)
161 assert issue.is_a?(Issue)
162 assert !issue.new_record?
162 assert !issue.new_record?
163 issue.reload
163 issue.reload
164 assert_equal 'Ticket created by email with attachment', issue.subject
164 assert_equal 'Ticket created by email with attachment', issue.subject
165 assert_equal User.find_by_login('jsmith'), issue.author
165 assert_equal User.find_by_login('jsmith'), issue.author
166 assert_equal Project.find(2), issue.project
166 assert_equal Project.find(2), issue.project
167 assert_equal 'This is a new ticket with attachments', issue.description
167 assert_equal 'This is a new ticket with attachments', issue.description
168 # Attachment properties
168 # Attachment properties
169 assert_equal 1, issue.attachments.size
169 assert_equal 1, issue.attachments.size
170 assert_equal 'Paella.jpg', issue.attachments.first.filename
170 assert_equal 'Paella.jpg', issue.attachments.first.filename
171 assert_equal 'image/jpeg', issue.attachments.first.content_type
171 assert_equal 'image/jpeg', issue.attachments.first.content_type
172 assert_equal 10790, issue.attachments.first.filesize
172 assert_equal 10790, issue.attachments.first.filesize
173 end
173 end
174
174
175 def test_add_issue_with_custom_fields
175 def test_add_issue_with_custom_fields
176 issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'onlinestore'})
176 issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'onlinestore'})
177 assert issue.is_a?(Issue)
177 assert issue.is_a?(Issue)
178 assert !issue.new_record?
178 assert !issue.new_record?
179 issue.reload
179 issue.reload
180 assert_equal 'New ticket with custom field values', issue.subject
180 assert_equal 'New ticket with custom field values', issue.subject
181 assert_equal 'PostgreSQL', issue.custom_field_value(1)
181 assert_equal 'PostgreSQL', issue.custom_field_value(1)
182 assert_equal 'Value for a custom field', issue.custom_field_value(2)
182 assert_equal 'Value for a custom field', issue.custom_field_value(2)
183 assert !issue.description.match(/^searchable field:/i)
183 assert !issue.description.match(/^searchable field:/i)
184 end
184 end
185
185
186 def test_add_issue_with_version_custom_fields
186 def test_add_issue_with_version_custom_fields
187 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1,2,3])
187 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1,2,3])
188
188
189 issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'ecookbook'}) do |email|
189 issue = submit_email('ticket_with_custom_fields.eml', :issue => {:project => 'ecookbook'}) do |email|
190 email << "Affected version: 1.0\n"
190 email << "Affected version: 1.0\n"
191 end
191 end
192 assert issue.is_a?(Issue)
192 assert issue.is_a?(Issue)
193 assert !issue.new_record?
193 assert !issue.new_record?
194 issue.reload
194 issue.reload
195 assert_equal '2', issue.custom_field_value(field)
195 assert_equal '2', issue.custom_field_value(field)
196 end
196 end
197
197
198 def test_add_issue_should_match_assignee_on_display_name
198 def test_add_issue_should_match_assignee_on_display_name
199 user = User.generate!(:firstname => 'Foo Bar', :lastname => 'Foo Baz')
199 user = User.generate!(:firstname => 'Foo Bar', :lastname => 'Foo Baz')
200 User.add_to_project(user, Project.find(2))
200 User.add_to_project(user, Project.find(2))
201 issue = submit_email('ticket_on_given_project.eml') do |email|
201 issue = submit_email('ticket_on_given_project.eml') do |email|
202 email.sub!(/^Assigned to.*$/, 'Assigned to: Foo Bar Foo baz')
202 email.sub!(/^Assigned to.*$/, 'Assigned to: Foo Bar Foo baz')
203 end
203 end
204 assert issue.is_a?(Issue)
204 assert issue.is_a?(Issue)
205 assert_equal user, issue.assigned_to
205 assert_equal user, issue.assigned_to
206 end
206 end
207
207
208 def test_add_issue_with_cc
208 def test_add_issue_with_cc
209 issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
209 issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
210 assert issue.is_a?(Issue)
210 assert issue.is_a?(Issue)
211 assert !issue.new_record?
211 assert !issue.new_record?
212 issue.reload
212 issue.reload
213 assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo'))
213 assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo'))
214 assert_equal 1, issue.watcher_user_ids.size
214 assert_equal 1, issue.watcher_user_ids.size
215 end
215 end
216
216
217 def test_add_issue_by_unknown_user
217 def test_add_issue_by_unknown_user
218 assert_no_difference 'User.count' do
218 assert_no_difference 'User.count' do
219 assert_equal false,
219 assert_equal false,
220 submit_email(
220 submit_email(
221 'ticket_by_unknown_user.eml',
221 'ticket_by_unknown_user.eml',
222 :issue => {:project => 'ecookbook'}
222 :issue => {:project => 'ecookbook'}
223 )
223 )
224 end
224 end
225 end
225 end
226
226
227 def test_add_issue_by_anonymous_user
227 def test_add_issue_by_anonymous_user
228 Role.anonymous.add_permission!(:add_issues)
228 Role.anonymous.add_permission!(:add_issues)
229 assert_no_difference 'User.count' do
229 assert_no_difference 'User.count' do
230 issue = submit_email(
230 issue = submit_email(
231 'ticket_by_unknown_user.eml',
231 'ticket_by_unknown_user.eml',
232 :issue => {:project => 'ecookbook'},
232 :issue => {:project => 'ecookbook'},
233 :unknown_user => 'accept'
233 :unknown_user => 'accept'
234 )
234 )
235 assert issue.is_a?(Issue)
235 assert issue.is_a?(Issue)
236 assert issue.author.anonymous?
236 assert issue.author.anonymous?
237 end
237 end
238 end
238 end
239
239
240 def test_add_issue_by_anonymous_user_with_no_from_address
240 def test_add_issue_by_anonymous_user_with_no_from_address
241 Role.anonymous.add_permission!(:add_issues)
241 Role.anonymous.add_permission!(:add_issues)
242 assert_no_difference 'User.count' do
242 assert_no_difference 'User.count' do
243 issue = submit_email(
243 issue = submit_email(
244 'ticket_by_empty_user.eml',
244 'ticket_by_empty_user.eml',
245 :issue => {:project => 'ecookbook'},
245 :issue => {:project => 'ecookbook'},
246 :unknown_user => 'accept'
246 :unknown_user => 'accept'
247 )
247 )
248 assert issue.is_a?(Issue)
248 assert issue.is_a?(Issue)
249 assert issue.author.anonymous?
249 assert issue.author.anonymous?
250 end
250 end
251 end
251 end
252
252
253 def test_add_issue_by_anonymous_user_on_private_project
253 def test_add_issue_by_anonymous_user_on_private_project
254 Role.anonymous.add_permission!(:add_issues)
254 Role.anonymous.add_permission!(:add_issues)
255 assert_no_difference 'User.count' do
255 assert_no_difference 'User.count' do
256 assert_no_difference 'Issue.count' do
256 assert_no_difference 'Issue.count' do
257 assert_equal false,
257 assert_equal false,
258 submit_email(
258 submit_email(
259 'ticket_by_unknown_user.eml',
259 'ticket_by_unknown_user.eml',
260 :issue => {:project => 'onlinestore'},
260 :issue => {:project => 'onlinestore'},
261 :unknown_user => 'accept'
261 :unknown_user => 'accept'
262 )
262 )
263 end
263 end
264 end
264 end
265 end
265 end
266
266
267 def test_add_issue_by_anonymous_user_on_private_project_without_permission_check
267 def test_add_issue_by_anonymous_user_on_private_project_without_permission_check
268 lft1 = new_issue_lft
268 lft1 = new_issue_lft
269 assert_no_difference 'User.count' do
269 assert_no_difference 'User.count' do
270 assert_difference 'Issue.count' do
270 assert_difference 'Issue.count' do
271 issue = submit_email(
271 issue = submit_email(
272 'ticket_by_unknown_user.eml',
272 'ticket_by_unknown_user.eml',
273 :issue => {:project => 'onlinestore'},
273 :issue => {:project => 'onlinestore'},
274 :no_permission_check => '1',
274 :no_permission_check => '1',
275 :unknown_user => 'accept'
275 :unknown_user => 'accept'
276 )
276 )
277 assert issue.is_a?(Issue)
277 assert issue.is_a?(Issue)
278 assert issue.author.anonymous?
278 assert issue.author.anonymous?
279 assert !issue.project.is_public?
279 assert !issue.project.is_public?
280 assert_equal [issue.id, lft1, lft1 + 1], [issue.root_id, issue.lft, issue.rgt]
280 assert_equal [issue.id, lft1, lft1 + 1], [issue.root_id, issue.lft, issue.rgt]
281 end
281 end
282 end
282 end
283 end
283 end
284
284
285 def test_add_issue_by_created_user
285 def test_add_issue_by_created_user
286 Setting.default_language = 'en'
286 Setting.default_language = 'en'
287 assert_difference 'User.count' do
287 assert_difference 'User.count' do
288 issue = submit_email(
288 issue = submit_email(
289 'ticket_by_unknown_user.eml',
289 'ticket_by_unknown_user.eml',
290 :issue => {:project => 'ecookbook'},
290 :issue => {:project => 'ecookbook'},
291 :unknown_user => 'create'
291 :unknown_user => 'create'
292 )
292 )
293 assert issue.is_a?(Issue)
293 assert issue.is_a?(Issue)
294 assert issue.author.active?
294 assert issue.author.active?
295 assert_equal 'john.doe@somenet.foo', issue.author.mail
295 assert_equal 'john.doe@somenet.foo', issue.author.mail
296 assert_equal 'John', issue.author.firstname
296 assert_equal 'John', issue.author.firstname
297 assert_equal 'Doe', issue.author.lastname
297 assert_equal 'Doe', issue.author.lastname
298
298
299 # account information
299 # account information
300 email = ActionMailer::Base.deliveries.first
300 email = ActionMailer::Base.deliveries.first
301 assert_not_nil email
301 assert_not_nil email
302 assert email.subject.include?('account activation')
302 assert email.subject.include?('account activation')
303 login = mail_body(email).match(/\* Login: (.*)$/)[1].strip
303 login = mail_body(email).match(/\* Login: (.*)$/)[1].strip
304 password = mail_body(email).match(/\* Password: (.*)$/)[1].strip
304 password = mail_body(email).match(/\* Password: (.*)$/)[1].strip
305 assert_equal issue.author, User.try_to_login(login, password)
305 assert_equal issue.author, User.try_to_login(login, password)
306 end
306 end
307 end
307 end
308
308
309 def test_created_user_should_be_added_to_groups
309 def test_created_user_should_be_added_to_groups
310 group1 = Group.generate!
310 group1 = Group.generate!
311 group2 = Group.generate!
311 group2 = Group.generate!
312
312
313 assert_difference 'User.count' do
313 assert_difference 'User.count' do
314 submit_email(
314 submit_email(
315 'ticket_by_unknown_user.eml',
315 'ticket_by_unknown_user.eml',
316 :issue => {:project => 'ecookbook'},
316 :issue => {:project => 'ecookbook'},
317 :unknown_user => 'create',
317 :unknown_user => 'create',
318 :default_group => "#{group1.name},#{group2.name}"
318 :default_group => "#{group1.name},#{group2.name}"
319 )
319 )
320 end
320 end
321 user = User.order('id DESC').first
321 user = User.order('id DESC').first
322 assert_same_elements [group1, group2], user.groups
322 assert_same_elements [group1, group2], user.groups
323 end
323 end
324
324
325 def test_created_user_should_not_receive_account_information_with_no_account_info_option
325 def test_created_user_should_not_receive_account_information_with_no_account_info_option
326 assert_difference 'User.count' do
326 assert_difference 'User.count' do
327 submit_email(
327 submit_email(
328 'ticket_by_unknown_user.eml',
328 'ticket_by_unknown_user.eml',
329 :issue => {:project => 'ecookbook'},
329 :issue => {:project => 'ecookbook'},
330 :unknown_user => 'create',
330 :unknown_user => 'create',
331 :no_account_notice => '1'
331 :no_account_notice => '1'
332 )
332 )
333 end
333 end
334
334
335 # only 1 email for the new issue notification
335 # only 1 email for the new issue notification
336 assert_equal 1, ActionMailer::Base.deliveries.size
336 assert_equal 1, ActionMailer::Base.deliveries.size
337 email = ActionMailer::Base.deliveries.first
337 email = ActionMailer::Base.deliveries.first
338 assert_include 'Ticket by unknown user', email.subject
338 assert_include 'Ticket by unknown user', email.subject
339 end
339 end
340
340
341 def test_created_user_should_have_mail_notification_to_none_with_no_notification_option
341 def test_created_user_should_have_mail_notification_to_none_with_no_notification_option
342 assert_difference 'User.count' do
342 assert_difference 'User.count' do
343 submit_email(
343 submit_email(
344 'ticket_by_unknown_user.eml',
344 'ticket_by_unknown_user.eml',
345 :issue => {:project => 'ecookbook'},
345 :issue => {:project => 'ecookbook'},
346 :unknown_user => 'create',
346 :unknown_user => 'create',
347 :no_notification => '1'
347 :no_notification => '1'
348 )
348 )
349 end
349 end
350 user = User.order('id DESC').first
350 user = User.order('id DESC').first
351 assert_equal 'none', user.mail_notification
351 assert_equal 'none', user.mail_notification
352 end
352 end
353
353
354 def test_add_issue_without_from_header
354 def test_add_issue_without_from_header
355 Role.anonymous.add_permission!(:add_issues)
355 Role.anonymous.add_permission!(:add_issues)
356 assert_equal false, submit_email('ticket_without_from_header.eml')
356 assert_equal false, submit_email('ticket_without_from_header.eml')
357 end
357 end
358
358
359 def test_add_issue_with_invalid_attributes
359 def test_add_issue_with_invalid_attributes
360 issue = submit_email(
360 issue = submit_email(
361 'ticket_with_invalid_attributes.eml',
361 'ticket_with_invalid_attributes.eml',
362 :allow_override => 'tracker,category,priority'
362 :allow_override => 'tracker,category,priority'
363 )
363 )
364 assert issue.is_a?(Issue)
364 assert issue.is_a?(Issue)
365 assert !issue.new_record?
365 assert !issue.new_record?
366 issue.reload
366 issue.reload
367 assert_nil issue.assigned_to
367 assert_nil issue.assigned_to
368 assert_nil issue.start_date
368 assert_nil issue.start_date
369 assert_nil issue.due_date
369 assert_nil issue.due_date
370 assert_equal 0, issue.done_ratio
370 assert_equal 0, issue.done_ratio
371 assert_equal 'Normal', issue.priority.to_s
371 assert_equal 'Normal', issue.priority.to_s
372 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
372 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
373 end
373 end
374
374
375 def test_add_issue_with_invalid_project_should_be_assigned_to_default_project
375 def test_add_issue_with_invalid_project_should_be_assigned_to_default_project
376 issue = submit_email('ticket_on_given_project.eml', :issue => {:project => 'ecookbook'}, :allow_override => 'project') do |email|
376 issue = submit_email('ticket_on_given_project.eml', :issue => {:project => 'ecookbook'}, :allow_override => 'project') do |email|
377 email.gsub!(/^Project:.+$/, 'Project: invalid')
377 email.gsub!(/^Project:.+$/, 'Project: invalid')
378 end
378 end
379 assert issue.is_a?(Issue)
379 assert issue.is_a?(Issue)
380 assert !issue.new_record?
380 assert !issue.new_record?
381 assert_equal 'ecookbook', issue.project.identifier
381 assert_equal 'ecookbook', issue.project.identifier
382 end
382 end
383
383
384 def test_add_issue_with_localized_attributes
384 def test_add_issue_with_localized_attributes
385 User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
385 User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
386 issue = submit_email(
386 issue = submit_email(
387 'ticket_with_localized_attributes.eml',
387 'ticket_with_localized_attributes.eml',
388 :allow_override => 'tracker,category,priority'
388 :allow_override => 'tracker,category,priority'
389 )
389 )
390 assert issue.is_a?(Issue)
390 assert issue.is_a?(Issue)
391 assert !issue.new_record?
391 assert !issue.new_record?
392 issue.reload
392 issue.reload
393 assert_equal 'New ticket on a given project', issue.subject
393 assert_equal 'New ticket on a given project', issue.subject
394 assert_equal User.find_by_login('jsmith'), issue.author
394 assert_equal User.find_by_login('jsmith'), issue.author
395 assert_equal Project.find(2), issue.project
395 assert_equal Project.find(2), issue.project
396 assert_equal 'Feature request', issue.tracker.to_s
396 assert_equal 'Feature request', issue.tracker.to_s
397 assert_equal 'Stock management', issue.category.to_s
397 assert_equal 'Stock management', issue.category.to_s
398 assert_equal 'Urgent', issue.priority.to_s
398 assert_equal 'Urgent', issue.priority.to_s
399 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
399 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
400 end
400 end
401
401
402 def test_add_issue_with_japanese_keywords
402 def test_add_issue_with_japanese_keywords
403 ja_dev = "\xe9\x96\x8b\xe7\x99\xba"
403 ja_dev = "\xe9\x96\x8b\xe7\x99\xba"
404 ja_dev.force_encoding('UTF-8') if ja_dev.respond_to?(:force_encoding)
404 ja_dev.force_encoding('UTF-8') if ja_dev.respond_to?(:force_encoding)
405 tracker = Tracker.create!(:name => ja_dev)
405 tracker = Tracker.create!(:name => ja_dev)
406 Project.find(1).trackers << tracker
406 Project.find(1).trackers << tracker
407 issue = submit_email(
407 issue = submit_email(
408 'japanese_keywords_iso_2022_jp.eml',
408 'japanese_keywords_iso_2022_jp.eml',
409 :issue => {:project => 'ecookbook'},
409 :issue => {:project => 'ecookbook'},
410 :allow_override => 'tracker'
410 :allow_override => 'tracker'
411 )
411 )
412 assert_kind_of Issue, issue
412 assert_kind_of Issue, issue
413 assert_equal tracker, issue.tracker
413 assert_equal tracker, issue.tracker
414 end
414 end
415
415
416 def test_add_issue_from_apple_mail
416 def test_add_issue_from_apple_mail
417 issue = submit_email(
417 issue = submit_email(
418 'apple_mail_with_attachment.eml',
418 'apple_mail_with_attachment.eml',
419 :issue => {:project => 'ecookbook'}
419 :issue => {:project => 'ecookbook'}
420 )
420 )
421 assert_kind_of Issue, issue
421 assert_kind_of Issue, issue
422 assert_equal 1, issue.attachments.size
422 assert_equal 1, issue.attachments.size
423
423
424 attachment = issue.attachments.first
424 attachment = issue.attachments.first
425 assert_equal 'paella.jpg', attachment.filename
425 assert_equal 'paella.jpg', attachment.filename
426 assert_equal 10790, attachment.filesize
426 assert_equal 10790, attachment.filesize
427 assert File.exist?(attachment.diskfile)
427 assert File.exist?(attachment.diskfile)
428 assert_equal 10790, File.size(attachment.diskfile)
428 assert_equal 10790, File.size(attachment.diskfile)
429 assert_equal 'caaf384198bcbc9563ab5c058acd73cd', attachment.digest
429 assert_equal 'caaf384198bcbc9563ab5c058acd73cd', attachment.digest
430 end
430 end
431
431
432 def test_thunderbird_with_attachment_ja
432 def test_thunderbird_with_attachment_ja
433 issue = submit_email(
433 issue = submit_email(
434 'thunderbird_with_attachment_ja.eml',
434 'thunderbird_with_attachment_ja.eml',
435 :issue => {:project => 'ecookbook'}
435 :issue => {:project => 'ecookbook'}
436 )
436 )
437 assert_kind_of Issue, issue
437 assert_kind_of Issue, issue
438 assert_equal 1, issue.attachments.size
438 assert_equal 1, issue.attachments.size
439 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt"
439 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt"
440 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
440 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
441 attachment = issue.attachments.first
441 attachment = issue.attachments.first
442 assert_equal ja, attachment.filename
442 assert_equal ja, attachment.filename
443 assert_equal 5, attachment.filesize
443 assert_equal 5, attachment.filesize
444 assert File.exist?(attachment.diskfile)
444 assert File.exist?(attachment.diskfile)
445 assert_equal 5, File.size(attachment.diskfile)
445 assert_equal 5, File.size(attachment.diskfile)
446 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
446 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
447 end
447 end
448
448
449 def test_gmail_with_attachment_ja
449 def test_gmail_with_attachment_ja
450 issue = submit_email(
450 issue = submit_email(
451 'gmail_with_attachment_ja.eml',
451 'gmail_with_attachment_ja.eml',
452 :issue => {:project => 'ecookbook'}
452 :issue => {:project => 'ecookbook'}
453 )
453 )
454 assert_kind_of Issue, issue
454 assert_kind_of Issue, issue
455 assert_equal 1, issue.attachments.size
455 assert_equal 1, issue.attachments.size
456 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt"
456 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt"
457 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
457 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
458 attachment = issue.attachments.first
458 attachment = issue.attachments.first
459 assert_equal ja, attachment.filename
459 assert_equal ja, attachment.filename
460 assert_equal 5, attachment.filesize
460 assert_equal 5, attachment.filesize
461 assert File.exist?(attachment.diskfile)
461 assert File.exist?(attachment.diskfile)
462 assert_equal 5, File.size(attachment.diskfile)
462 assert_equal 5, File.size(attachment.diskfile)
463 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
463 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
464 end
464 end
465
465
466 def test_thunderbird_with_attachment_latin1
466 def test_thunderbird_with_attachment_latin1
467 issue = submit_email(
467 issue = submit_email(
468 'thunderbird_with_attachment_iso-8859-1.eml',
468 'thunderbird_with_attachment_iso-8859-1.eml',
469 :issue => {:project => 'ecookbook'}
469 :issue => {:project => 'ecookbook'}
470 )
470 )
471 assert_kind_of Issue, issue
471 assert_kind_of Issue, issue
472 assert_equal 1, issue.attachments.size
472 assert_equal 1, issue.attachments.size
473 u = ""
473 u = ""
474 u.force_encoding('UTF-8') if u.respond_to?(:force_encoding)
474 u.force_encoding('UTF-8') if u.respond_to?(:force_encoding)
475 u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc"
475 u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc"
476 u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding)
476 u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding)
477 11.times { u << u1 }
477 11.times { u << u1 }
478 attachment = issue.attachments.first
478 attachment = issue.attachments.first
479 assert_equal "#{u}.png", attachment.filename
479 assert_equal "#{u}.png", attachment.filename
480 assert_equal 130, attachment.filesize
480 assert_equal 130, attachment.filesize
481 assert File.exist?(attachment.diskfile)
481 assert File.exist?(attachment.diskfile)
482 assert_equal 130, File.size(attachment.diskfile)
482 assert_equal 130, File.size(attachment.diskfile)
483 assert_equal '4d80e667ac37dddfe05502530f152abb', attachment.digest
483 assert_equal '4d80e667ac37dddfe05502530f152abb', attachment.digest
484 end
484 end
485
485
486 def test_gmail_with_attachment_latin1
486 def test_gmail_with_attachment_latin1
487 issue = submit_email(
487 issue = submit_email(
488 'gmail_with_attachment_iso-8859-1.eml',
488 'gmail_with_attachment_iso-8859-1.eml',
489 :issue => {:project => 'ecookbook'}
489 :issue => {:project => 'ecookbook'}
490 )
490 )
491 assert_kind_of Issue, issue
491 assert_kind_of Issue, issue
492 assert_equal 1, issue.attachments.size
492 assert_equal 1, issue.attachments.size
493 u = ""
493 u = ""
494 u.force_encoding('UTF-8') if u.respond_to?(:force_encoding)
494 u.force_encoding('UTF-8') if u.respond_to?(:force_encoding)
495 u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc"
495 u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc"
496 u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding)
496 u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding)
497 11.times { u << u1 }
497 11.times { u << u1 }
498 attachment = issue.attachments.first
498 attachment = issue.attachments.first
499 assert_equal "#{u}.txt", attachment.filename
499 assert_equal "#{u}.txt", attachment.filename
500 assert_equal 5, attachment.filesize
500 assert_equal 5, attachment.filesize
501 assert File.exist?(attachment.diskfile)
501 assert File.exist?(attachment.diskfile)
502 assert_equal 5, File.size(attachment.diskfile)
502 assert_equal 5, File.size(attachment.diskfile)
503 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
503 assert_equal 'd8e8fca2dc0f896fd7cb4cb0031ba249', attachment.digest
504 end
504 end
505
505
506 def test_multiple_inline_text_parts_should_be_appended_to_issue_description
506 def test_multiple_inline_text_parts_should_be_appended_to_issue_description
507 issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
507 issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
508 assert_include 'first', issue.description
508 assert_include 'first', issue.description
509 assert_include 'second', issue.description
509 assert_include 'second', issue.description
510 assert_include 'third', issue.description
510 assert_include 'third', issue.description
511 end
511 end
512
512
513 def test_attachment_text_part_should_be_added_as_issue_attachment
513 def test_attachment_text_part_should_be_added_as_issue_attachment
514 issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
514 issue = submit_email('multiple_text_parts.eml', :issue => {:project => 'ecookbook'})
515 assert_not_include 'Plain text attachment', issue.description
515 assert_not_include 'Plain text attachment', issue.description
516 attachment = issue.attachments.detect {|a| a.filename == 'textfile.txt'}
516 attachment = issue.attachments.detect {|a| a.filename == 'textfile.txt'}
517 assert_not_nil attachment
517 assert_not_nil attachment
518 assert_include 'Plain text attachment', File.read(attachment.diskfile)
518 assert_include 'Plain text attachment', File.read(attachment.diskfile)
519 end
519 end
520
520
521 def test_add_issue_with_iso_8859_1_subject
521 def test_add_issue_with_iso_8859_1_subject
522 issue = submit_email(
522 issue = submit_email(
523 'subject_as_iso-8859-1.eml',
523 'subject_as_iso-8859-1.eml',
524 :issue => {:project => 'ecookbook'}
524 :issue => {:project => 'ecookbook'}
525 )
525 )
526 str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc..."
526 str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc..."
527 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
527 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
528 assert_kind_of Issue, issue
528 assert_kind_of Issue, issue
529 assert_equal str, issue.subject
529 assert_equal str, issue.subject
530 end
530 end
531
531
532 def test_quoted_printable_utf8
533 issue = submit_email(
534 'quoted_printable_utf8.eml',
535 :issue => {:project => 'ecookbook'}
536 )
537 assert_kind_of Issue, issue
538 str = "Freundliche Gr\xc3\xbcsse"
539 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
540 assert_equal str, issue.description
541 end
542
532 def test_add_issue_with_japanese_subject
543 def test_add_issue_with_japanese_subject
533 issue = submit_email(
544 issue = submit_email(
534 'subject_japanese_1.eml',
545 'subject_japanese_1.eml',
535 :issue => {:project => 'ecookbook'}
546 :issue => {:project => 'ecookbook'}
536 )
547 )
537 assert_kind_of Issue, issue
548 assert_kind_of Issue, issue
538 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88"
549 ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88"
539 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
550 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
540 assert_equal ja, issue.subject
551 assert_equal ja, issue.subject
541 end
552 end
542
553
543 def test_add_issue_with_korean_body
554 def test_add_issue_with_korean_body
544 # Make sure mail bodies with a charset unknown to Ruby
555 # Make sure mail bodies with a charset unknown to Ruby
545 # but known to the Mail gem 2.5.4 are handled correctly
556 # but known to the Mail gem 2.5.4 are handled correctly
546 kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4."
557 kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4."
547 if !kr.respond_to?(:force_encoding)
558 if !kr.respond_to?(:force_encoding)
548 puts "\nOn Ruby 1.8, skip Korean encoding mail body test"
559 puts "\nOn Ruby 1.8, skip Korean encoding mail body test"
549 else
560 else
550 kr.force_encoding('UTF-8')
561 kr.force_encoding('UTF-8')
551 issue = submit_email(
562 issue = submit_email(
552 'body_ks_c_5601-1987.eml',
563 'body_ks_c_5601-1987.eml',
553 :issue => {:project => 'ecookbook'}
564 :issue => {:project => 'ecookbook'}
554 )
565 )
555 assert_kind_of Issue, issue
566 assert_kind_of Issue, issue
556 assert_equal kr, issue.description
567 assert_equal kr, issue.description
557 end
568 end
558 end
569 end
559
570
560 def test_add_issue_with_no_subject_header
571 def test_add_issue_with_no_subject_header
561 issue = submit_email(
572 issue = submit_email(
562 'no_subject_header.eml',
573 'no_subject_header.eml',
563 :issue => {:project => 'ecookbook'}
574 :issue => {:project => 'ecookbook'}
564 )
575 )
565 assert_kind_of Issue, issue
576 assert_kind_of Issue, issue
566 assert_equal '(no subject)', issue.subject
577 assert_equal '(no subject)', issue.subject
567 end
578 end
568
579
569 def test_add_issue_with_mixed_japanese_subject
580 def test_add_issue_with_mixed_japanese_subject
570 issue = submit_email(
581 issue = submit_email(
571 'subject_japanese_2.eml',
582 'subject_japanese_2.eml',
572 :issue => {:project => 'ecookbook'}
583 :issue => {:project => 'ecookbook'}
573 )
584 )
574 assert_kind_of Issue, issue
585 assert_kind_of Issue, issue
575 ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88"
586 ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88"
576 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
587 ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
577 assert_equal ja, issue.subject
588 assert_equal ja, issue.subject
578 end
589 end
579
590
580 def test_should_ignore_emails_from_locked_users
591 def test_should_ignore_emails_from_locked_users
581 User.find(2).lock!
592 User.find(2).lock!
582
593
583 MailHandler.any_instance.expects(:dispatch).never
594 MailHandler.any_instance.expects(:dispatch).never
584 assert_no_difference 'Issue.count' do
595 assert_no_difference 'Issue.count' do
585 assert_equal false, submit_email('ticket_on_given_project.eml')
596 assert_equal false, submit_email('ticket_on_given_project.eml')
586 end
597 end
587 end
598 end
588
599
589 def test_should_ignore_emails_from_emission_address
600 def test_should_ignore_emails_from_emission_address
590 Role.anonymous.add_permission!(:add_issues)
601 Role.anonymous.add_permission!(:add_issues)
591 assert_no_difference 'User.count' do
602 assert_no_difference 'User.count' do
592 assert_equal false,
603 assert_equal false,
593 submit_email(
604 submit_email(
594 'ticket_from_emission_address.eml',
605 'ticket_from_emission_address.eml',
595 :issue => {:project => 'ecookbook'},
606 :issue => {:project => 'ecookbook'},
596 :unknown_user => 'create'
607 :unknown_user => 'create'
597 )
608 )
598 end
609 end
599 end
610 end
600
611
601 def test_should_ignore_auto_replied_emails
612 def test_should_ignore_auto_replied_emails
602 MailHandler.any_instance.expects(:dispatch).never
613 MailHandler.any_instance.expects(:dispatch).never
603 [
614 [
604 "X-Auto-Response-Suppress: OOF",
615 "X-Auto-Response-Suppress: OOF",
605 "Auto-Submitted: auto-replied",
616 "Auto-Submitted: auto-replied",
606 "Auto-Submitted: Auto-Replied",
617 "Auto-Submitted: Auto-Replied",
607 "Auto-Submitted: auto-generated"
618 "Auto-Submitted: auto-generated"
608 ].each do |header|
619 ].each do |header|
609 raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
620 raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
610 raw = header + "\n" + raw
621 raw = header + "\n" + raw
611
622
612 assert_no_difference 'Issue.count' do
623 assert_no_difference 'Issue.count' do
613 assert_equal false, MailHandler.receive(raw), "email with #{header} header was not ignored"
624 assert_equal false, MailHandler.receive(raw), "email with #{header} header was not ignored"
614 end
625 end
615 end
626 end
616 end
627 end
617
628
618 def test_add_issue_should_send_email_notification
629 def test_add_issue_should_send_email_notification
619 Setting.notified_events = ['issue_added']
630 Setting.notified_events = ['issue_added']
620 ActionMailer::Base.deliveries.clear
631 ActionMailer::Base.deliveries.clear
621 # This email contains: 'Project: onlinestore'
632 # This email contains: 'Project: onlinestore'
622 issue = submit_email('ticket_on_given_project.eml')
633 issue = submit_email('ticket_on_given_project.eml')
623 assert issue.is_a?(Issue)
634 assert issue.is_a?(Issue)
624 assert_equal 1, ActionMailer::Base.deliveries.size
635 assert_equal 1, ActionMailer::Base.deliveries.size
625 end
636 end
626
637
627 def test_update_issue
638 def test_update_issue
628 journal = submit_email('ticket_reply.eml')
639 journal = submit_email('ticket_reply.eml')
629 assert journal.is_a?(Journal)
640 assert journal.is_a?(Journal)
630 assert_equal User.find_by_login('jsmith'), journal.user
641 assert_equal User.find_by_login('jsmith'), journal.user
631 assert_equal Issue.find(2), journal.journalized
642 assert_equal Issue.find(2), journal.journalized
632 assert_match /This is reply/, journal.notes
643 assert_match /This is reply/, journal.notes
633 assert_equal false, journal.private_notes
644 assert_equal false, journal.private_notes
634 assert_equal 'Feature request', journal.issue.tracker.name
645 assert_equal 'Feature request', journal.issue.tracker.name
635 end
646 end
636
647
637 def test_update_issue_with_attribute_changes
648 def test_update_issue_with_attribute_changes
638 # This email contains: 'Status: Resolved'
649 # This email contains: 'Status: Resolved'
639 journal = submit_email('ticket_reply_with_status.eml')
650 journal = submit_email('ticket_reply_with_status.eml')
640 assert journal.is_a?(Journal)
651 assert journal.is_a?(Journal)
641 issue = Issue.find(journal.issue.id)
652 issue = Issue.find(journal.issue.id)
642 assert_equal User.find_by_login('jsmith'), journal.user
653 assert_equal User.find_by_login('jsmith'), journal.user
643 assert_equal Issue.find(2), journal.journalized
654 assert_equal Issue.find(2), journal.journalized
644 assert_match /This is reply/, journal.notes
655 assert_match /This is reply/, journal.notes
645 assert_equal 'Feature request', journal.issue.tracker.name
656 assert_equal 'Feature request', journal.issue.tracker.name
646 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
657 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
647 assert_equal '2010-01-01', issue.start_date.to_s
658 assert_equal '2010-01-01', issue.start_date.to_s
648 assert_equal '2010-12-31', issue.due_date.to_s
659 assert_equal '2010-12-31', issue.due_date.to_s
649 assert_equal User.find_by_login('jsmith'), issue.assigned_to
660 assert_equal User.find_by_login('jsmith'), issue.assigned_to
650 assert_equal "52.6", issue.custom_value_for(CustomField.find_by_name('Float field')).value
661 assert_equal "52.6", issue.custom_value_for(CustomField.find_by_name('Float field')).value
651 # keywords should be removed from the email body
662 # keywords should be removed from the email body
652 assert !journal.notes.match(/^Status:/i)
663 assert !journal.notes.match(/^Status:/i)
653 assert !journal.notes.match(/^Start Date:/i)
664 assert !journal.notes.match(/^Start Date:/i)
654 end
665 end
655
666
656 def test_update_issue_with_attachment
667 def test_update_issue_with_attachment
657 assert_difference 'Journal.count' do
668 assert_difference 'Journal.count' do
658 assert_difference 'JournalDetail.count' do
669 assert_difference 'JournalDetail.count' do
659 assert_difference 'Attachment.count' do
670 assert_difference 'Attachment.count' do
660 assert_no_difference 'Issue.count' do
671 assert_no_difference 'Issue.count' do
661 journal = submit_email('ticket_with_attachment.eml') do |raw|
672 journal = submit_email('ticket_with_attachment.eml') do |raw|
662 raw.gsub! /^Subject: .*$/, 'Subject: Re: [Cookbook - Feature #2] (New) Add ingredients categories'
673 raw.gsub! /^Subject: .*$/, 'Subject: Re: [Cookbook - Feature #2] (New) Add ingredients categories'
663 end
674 end
664 end
675 end
665 end
676 end
666 end
677 end
667 end
678 end
668 journal = Journal.order('id DESC').first
679 journal = Journal.order('id DESC').first
669 assert_equal Issue.find(2), journal.journalized
680 assert_equal Issue.find(2), journal.journalized
670 assert_equal 1, journal.details.size
681 assert_equal 1, journal.details.size
671
682
672 detail = journal.details.first
683 detail = journal.details.first
673 assert_equal 'attachment', detail.property
684 assert_equal 'attachment', detail.property
674 assert_equal 'Paella.jpg', detail.value
685 assert_equal 'Paella.jpg', detail.value
675 end
686 end
676
687
677 def test_update_issue_should_send_email_notification
688 def test_update_issue_should_send_email_notification
678 ActionMailer::Base.deliveries.clear
689 ActionMailer::Base.deliveries.clear
679 journal = submit_email('ticket_reply.eml')
690 journal = submit_email('ticket_reply.eml')
680 assert journal.is_a?(Journal)
691 assert journal.is_a?(Journal)
681 assert_equal 1, ActionMailer::Base.deliveries.size
692 assert_equal 1, ActionMailer::Base.deliveries.size
682 end
693 end
683
694
684 def test_update_issue_should_not_set_defaults
695 def test_update_issue_should_not_set_defaults
685 journal = submit_email(
696 journal = submit_email(
686 'ticket_reply.eml',
697 'ticket_reply.eml',
687 :issue => {:tracker => 'Support request', :priority => 'High'}
698 :issue => {:tracker => 'Support request', :priority => 'High'}
688 )
699 )
689 assert journal.is_a?(Journal)
700 assert journal.is_a?(Journal)
690 assert_match /This is reply/, journal.notes
701 assert_match /This is reply/, journal.notes
691 assert_equal 'Feature request', journal.issue.tracker.name
702 assert_equal 'Feature request', journal.issue.tracker.name
692 assert_equal 'Normal', journal.issue.priority.name
703 assert_equal 'Normal', journal.issue.priority.name
693 end
704 end
694
705
695 def test_replying_to_a_private_note_should_add_reply_as_private
706 def test_replying_to_a_private_note_should_add_reply_as_private
696 private_journal = Journal.create!(:notes => 'Private notes', :journalized => Issue.find(1), :private_notes => true, :user_id => 2)
707 private_journal = Journal.create!(:notes => 'Private notes', :journalized => Issue.find(1), :private_notes => true, :user_id => 2)
697
708
698 assert_difference 'Journal.count' do
709 assert_difference 'Journal.count' do
699 journal = submit_email('ticket_reply.eml') do |email|
710 journal = submit_email('ticket_reply.eml') do |email|
700 email.sub! %r{^In-Reply-To:.*$}, "In-Reply-To: <redmine.journal-#{private_journal.id}.20060719210421@osiris>"
711 email.sub! %r{^In-Reply-To:.*$}, "In-Reply-To: <redmine.journal-#{private_journal.id}.20060719210421@osiris>"
701 end
712 end
702
713
703 assert_kind_of Journal, journal
714 assert_kind_of Journal, journal
704 assert_match /This is reply/, journal.notes
715 assert_match /This is reply/, journal.notes
705 assert_equal true, journal.private_notes
716 assert_equal true, journal.private_notes
706 end
717 end
707 end
718 end
708
719
709 def test_reply_to_a_message
720 def test_reply_to_a_message
710 m = submit_email('message_reply.eml')
721 m = submit_email('message_reply.eml')
711 assert m.is_a?(Message)
722 assert m.is_a?(Message)
712 assert !m.new_record?
723 assert !m.new_record?
713 m.reload
724 m.reload
714 assert_equal 'Reply via email', m.subject
725 assert_equal 'Reply via email', m.subject
715 # The email replies to message #2 which is part of the thread of message #1
726 # The email replies to message #2 which is part of the thread of message #1
716 assert_equal Message.find(1), m.parent
727 assert_equal Message.find(1), m.parent
717 end
728 end
718
729
719 def test_reply_to_a_message_by_subject
730 def test_reply_to_a_message_by_subject
720 m = submit_email('message_reply_by_subject.eml')
731 m = submit_email('message_reply_by_subject.eml')
721 assert m.is_a?(Message)
732 assert m.is_a?(Message)
722 assert !m.new_record?
733 assert !m.new_record?
723 m.reload
734 m.reload
724 assert_equal 'Reply to the first post', m.subject
735 assert_equal 'Reply to the first post', m.subject
725 assert_equal Message.find(1), m.parent
736 assert_equal Message.find(1), m.parent
726 end
737 end
727
738
728 def test_should_strip_tags_of_html_only_emails
739 def test_should_strip_tags_of_html_only_emails
729 issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
740 issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
730 assert issue.is_a?(Issue)
741 assert issue.is_a?(Issue)
731 assert !issue.new_record?
742 assert !issue.new_record?
732 issue.reload
743 issue.reload
733 assert_equal 'HTML email', issue.subject
744 assert_equal 'HTML email', issue.subject
734 assert_equal 'This is a html-only email.', issue.description
745 assert_equal 'This is a html-only email.', issue.description
735 end
746 end
736
747
737 test "truncate emails with no setting should add the entire email into the issue" do
748 test "truncate emails with no setting should add the entire email into the issue" do
738 with_settings :mail_handler_body_delimiters => '' do
749 with_settings :mail_handler_body_delimiters => '' do
739 issue = submit_email('ticket_on_given_project.eml')
750 issue = submit_email('ticket_on_given_project.eml')
740 assert_issue_created(issue)
751 assert_issue_created(issue)
741 assert issue.description.include?('---')
752 assert issue.description.include?('---')
742 assert issue.description.include?('This paragraph is after the delimiter')
753 assert issue.description.include?('This paragraph is after the delimiter')
743 end
754 end
744 end
755 end
745
756
746 test "truncate emails with a single string should truncate the email at the delimiter for the issue" do
757 test "truncate emails with a single string should truncate the email at the delimiter for the issue" do
747 with_settings :mail_handler_body_delimiters => '---' do
758 with_settings :mail_handler_body_delimiters => '---' do
748 issue = submit_email('ticket_on_given_project.eml')
759 issue = submit_email('ticket_on_given_project.eml')
749 assert_issue_created(issue)
760 assert_issue_created(issue)
750 assert issue.description.include?('This paragraph is before delimiters')
761 assert issue.description.include?('This paragraph is before delimiters')
751 assert issue.description.include?('--- This line starts with a delimiter')
762 assert issue.description.include?('--- This line starts with a delimiter')
752 assert !issue.description.match(/^---$/)
763 assert !issue.description.match(/^---$/)
753 assert !issue.description.include?('This paragraph is after the delimiter')
764 assert !issue.description.include?('This paragraph is after the delimiter')
754 end
765 end
755 end
766 end
756
767
757 test "truncate emails with a single quoted reply should truncate the email at the delimiter with the quoted reply symbols (>)" do
768 test "truncate emails with a single quoted reply should truncate the email at the delimiter with the quoted reply symbols (>)" do
758 with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
769 with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
759 journal = submit_email('issue_update_with_quoted_reply_above.eml')
770 journal = submit_email('issue_update_with_quoted_reply_above.eml')
760 assert journal.is_a?(Journal)
771 assert journal.is_a?(Journal)
761 assert journal.notes.include?('An update to the issue by the sender.')
772 assert journal.notes.include?('An update to the issue by the sender.')
762 assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
773 assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
763 assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
774 assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
764 end
775 end
765 end
776 end
766
777
767 test "truncate emails with multiple quoted replies should truncate the email at the delimiter with the quoted reply symbols (>)" do
778 test "truncate emails with multiple quoted replies should truncate the email at the delimiter with the quoted reply symbols (>)" do
768 with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
779 with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do
769 journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml')
780 journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml')
770 assert journal.is_a?(Journal)
781 assert journal.is_a?(Journal)
771 assert journal.notes.include?('An update to the issue by the sender.')
782 assert journal.notes.include?('An update to the issue by the sender.')
772 assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
783 assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
773 assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
784 assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
774 end
785 end
775 end
786 end
776
787
777 test "truncate emails with multiple strings should truncate the email at the first delimiter found (BREAK)" do
788 test "truncate emails with multiple strings should truncate the email at the first delimiter found (BREAK)" do
778 with_settings :mail_handler_body_delimiters => "---\nBREAK" do
789 with_settings :mail_handler_body_delimiters => "---\nBREAK" do
779 issue = submit_email('ticket_on_given_project.eml')
790 issue = submit_email('ticket_on_given_project.eml')
780 assert_issue_created(issue)
791 assert_issue_created(issue)
781 assert issue.description.include?('This paragraph is before delimiters')
792 assert issue.description.include?('This paragraph is before delimiters')
782 assert !issue.description.include?('BREAK')
793 assert !issue.description.include?('BREAK')
783 assert !issue.description.include?('This paragraph is between delimiters')
794 assert !issue.description.include?('This paragraph is between delimiters')
784 assert !issue.description.match(/^---$/)
795 assert !issue.description.match(/^---$/)
785 assert !issue.description.include?('This paragraph is after the delimiter')
796 assert !issue.description.include?('This paragraph is after the delimiter')
786 end
797 end
787 end
798 end
788
799
789 def test_attachments_that_match_mail_handler_excluded_filenames_should_be_ignored
800 def test_attachments_that_match_mail_handler_excluded_filenames_should_be_ignored
790 with_settings :mail_handler_excluded_filenames => '*.vcf, *.jpg' do
801 with_settings :mail_handler_excluded_filenames => '*.vcf, *.jpg' do
791 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
802 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
792 assert issue.is_a?(Issue)
803 assert issue.is_a?(Issue)
793 assert !issue.new_record?
804 assert !issue.new_record?
794 assert_equal 0, issue.reload.attachments.size
805 assert_equal 0, issue.reload.attachments.size
795 end
806 end
796 end
807 end
797
808
798 def test_attachments_that_do_not_match_mail_handler_excluded_filenames_should_be_attached
809 def test_attachments_that_do_not_match_mail_handler_excluded_filenames_should_be_attached
799 with_settings :mail_handler_excluded_filenames => '*.vcf, *.gif' do
810 with_settings :mail_handler_excluded_filenames => '*.vcf, *.gif' do
800 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
811 issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
801 assert issue.is_a?(Issue)
812 assert issue.is_a?(Issue)
802 assert !issue.new_record?
813 assert !issue.new_record?
803 assert_equal 1, issue.reload.attachments.size
814 assert_equal 1, issue.reload.attachments.size
804 end
815 end
805 end
816 end
806
817
807 def test_email_with_long_subject_line
818 def test_email_with_long_subject_line
808 issue = submit_email('ticket_with_long_subject.eml')
819 issue = submit_email('ticket_with_long_subject.eml')
809 assert issue.is_a?(Issue)
820 assert issue.is_a?(Issue)
810 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]
821 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]
811 end
822 end
812
823
813 def test_new_user_from_attributes_should_return_valid_user
824 def test_new_user_from_attributes_should_return_valid_user
814 to_test = {
825 to_test = {
815 # [address, name] => [login, firstname, lastname]
826 # [address, name] => [login, firstname, lastname]
816 ['jsmith@example.net', nil] => ['jsmith@example.net', 'jsmith', '-'],
827 ['jsmith@example.net', nil] => ['jsmith@example.net', 'jsmith', '-'],
817 ['jsmith@example.net', 'John'] => ['jsmith@example.net', 'John', '-'],
828 ['jsmith@example.net', 'John'] => ['jsmith@example.net', 'John', '-'],
818 ['jsmith@example.net', 'John Smith'] => ['jsmith@example.net', 'John', 'Smith'],
829 ['jsmith@example.net', 'John Smith'] => ['jsmith@example.net', 'John', 'Smith'],
819 ['jsmith@example.net', 'John Paul Smith'] => ['jsmith@example.net', 'John', 'Paul Smith'],
830 ['jsmith@example.net', 'John Paul Smith'] => ['jsmith@example.net', 'John', 'Paul Smith'],
820 ['jsmith@example.net', 'AVeryLongFirstnameThatExceedsTheMaximumLength Smith'] => ['jsmith@example.net', 'AVeryLongFirstnameThatExceedsT', 'Smith'],
831 ['jsmith@example.net', 'AVeryLongFirstnameThatExceedsTheMaximumLength Smith'] => ['jsmith@example.net', 'AVeryLongFirstnameThatExceedsT', 'Smith'],
821 ['jsmith@example.net', 'John AVeryLongLastnameThatExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', 'AVeryLongLastnameThatExceedsTh']
832 ['jsmith@example.net', 'John AVeryLongLastnameThatExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', 'AVeryLongLastnameThatExceedsTh']
822 }
833 }
823
834
824 to_test.each do |attrs, expected|
835 to_test.each do |attrs, expected|
825 user = MailHandler.new_user_from_attributes(attrs.first, attrs.last)
836 user = MailHandler.new_user_from_attributes(attrs.first, attrs.last)
826
837
827 assert user.valid?, user.errors.full_messages.to_s
838 assert user.valid?, user.errors.full_messages.to_s
828 assert_equal attrs.first, user.mail
839 assert_equal attrs.first, user.mail
829 assert_equal expected[0], user.login
840 assert_equal expected[0], user.login
830 assert_equal expected[1], user.firstname
841 assert_equal expected[1], user.firstname
831 assert_equal expected[2], user.lastname
842 assert_equal expected[2], user.lastname
832 assert_equal 'only_my_events', user.mail_notification
843 assert_equal 'only_my_events', user.mail_notification
833 end
844 end
834 end
845 end
835
846
836 def test_new_user_from_attributes_should_use_default_login_if_invalid
847 def test_new_user_from_attributes_should_use_default_login_if_invalid
837 user = MailHandler.new_user_from_attributes('foo+bar@example.net')
848 user = MailHandler.new_user_from_attributes('foo+bar@example.net')
838 assert user.valid?
849 assert user.valid?
839 assert user.login =~ /^user[a-f0-9]+$/
850 assert user.login =~ /^user[a-f0-9]+$/
840 assert_equal 'foo+bar@example.net', user.mail
851 assert_equal 'foo+bar@example.net', user.mail
841 end
852 end
842
853
843 def test_new_user_with_utf8_encoded_fullname_should_be_decoded
854 def test_new_user_with_utf8_encoded_fullname_should_be_decoded
844 assert_difference 'User.count' do
855 assert_difference 'User.count' do
845 issue = submit_email(
856 issue = submit_email(
846 'fullname_of_sender_as_utf8_encoded.eml',
857 'fullname_of_sender_as_utf8_encoded.eml',
847 :issue => {:project => 'ecookbook'},
858 :issue => {:project => 'ecookbook'},
848 :unknown_user => 'create'
859 :unknown_user => 'create'
849 )
860 )
850 end
861 end
851 user = User.order('id DESC').first
862 user = User.order('id DESC').first
852 assert_equal "foo@example.org", user.mail
863 assert_equal "foo@example.org", user.mail
853 str1 = "\xc3\x84\xc3\xa4"
864 str1 = "\xc3\x84\xc3\xa4"
854 str2 = "\xc3\x96\xc3\xb6"
865 str2 = "\xc3\x96\xc3\xb6"
855 str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
866 str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
856 str2.force_encoding('UTF-8') if str2.respond_to?(:force_encoding)
867 str2.force_encoding('UTF-8') if str2.respond_to?(:force_encoding)
857 assert_equal str1, user.firstname
868 assert_equal str1, user.firstname
858 assert_equal str2, user.lastname
869 assert_equal str2, user.lastname
859 end
870 end
860
871
861 def test_extract_options_from_env_should_return_options
872 def test_extract_options_from_env_should_return_options
862 options = MailHandler.extract_options_from_env({
873 options = MailHandler.extract_options_from_env({
863 'tracker' => 'defect',
874 'tracker' => 'defect',
864 'project' => 'foo',
875 'project' => 'foo',
865 'unknown_user' => 'create'
876 'unknown_user' => 'create'
866 })
877 })
867
878
868 assert_equal({
879 assert_equal({
869 :issue => {:tracker => 'defect', :project => 'foo'},
880 :issue => {:tracker => 'defect', :project => 'foo'},
870 :unknown_user => 'create'
881 :unknown_user => 'create'
871 }, options)
882 }, options)
872 end
883 end
873
884
874 private
885 private
875
886
876 def submit_email(filename, options={})
887 def submit_email(filename, options={})
877 raw = IO.read(File.join(FIXTURES_PATH, filename))
888 raw = IO.read(File.join(FIXTURES_PATH, filename))
878 yield raw if block_given?
889 yield raw if block_given?
879 MailHandler.receive(raw, options)
890 MailHandler.receive(raw, options)
880 end
891 end
881
892
882 def assert_issue_created(issue)
893 def assert_issue_created(issue)
883 assert issue.is_a?(Issue)
894 assert issue.is_a?(Issue)
884 assert !issue.new_record?
895 assert !issue.new_record?
885 issue.reload
896 issue.reload
886 end
897 end
887 end
898 end
General Comments 0
You need to be logged in to leave comments. Login now