@@ -67,7 +67,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
67 | 67 | |
|
68 | 68 | def test_add_issue_with_default_tracker |
|
69 | 69 | # This email contains: 'Project: onlinestore' |
|
70 | issue = submit_email('ticket_on_given_project.eml', :issue => {:tracker => 'Support request'}) | |
|
70 | issue = submit_email( | |
|
71 | 'ticket_on_given_project.eml', | |
|
72 | :issue => {:tracker => 'Support request'} | |
|
73 | ) | |
|
71 | 74 | assert issue.is_a?(Issue) |
|
72 | 75 | assert !issue.new_record? |
|
73 | 76 | issue.reload |
@@ -85,7 +88,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
85 | 88 | end |
|
86 | 89 | |
|
87 | 90 | def test_add_issue_with_attributes_override |
|
88 | issue = submit_email('ticket_with_attributes.eml', :allow_override => 'tracker,category,priority') | |
|
91 | issue = submit_email( | |
|
92 | 'ticket_with_attributes.eml', | |
|
93 | :allow_override => 'tracker,category,priority' | |
|
94 | ) | |
|
89 | 95 | assert issue.is_a?(Issue) |
|
90 | 96 | assert !issue.new_record? |
|
91 | 97 | issue.reload |
@@ -111,7 +117,11 class MailHandlerTest < ActiveSupport::TestCase | |||
|
111 | 117 | end |
|
112 | 118 | |
|
113 | 119 | def test_add_issue_with_partial_attributes_override |
|
114 | issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker']) | |
|
120 | issue = submit_email( | |
|
121 | 'ticket_with_attributes.eml', | |
|
122 | :issue => {:priority => 'High'}, | |
|
123 | :allow_override => ['tracker'] | |
|
124 | ) | |
|
115 | 125 | assert issue.is_a?(Issue) |
|
116 | 126 | assert !issue.new_record? |
|
117 | 127 | issue.reload |
@@ -125,7 +135,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
125 | 135 | end |
|
126 | 136 | |
|
127 | 137 | def test_add_issue_with_spaces_between_attribute_and_separator |
|
128 | issue = submit_email('ticket_with_spaces_between_attribute_and_separator.eml', :allow_override => 'tracker,category,priority') | |
|
138 | issue = submit_email( | |
|
139 | 'ticket_with_spaces_between_attribute_and_separator.eml', | |
|
140 | :allow_override => 'tracker,category,priority' | |
|
141 | ) | |
|
129 | 142 | assert issue.is_a?(Issue) |
|
130 | 143 | assert !issue.new_record? |
|
131 | 144 | issue.reload |
@@ -160,7 +173,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
160 | 173 | assert !issue.new_record? |
|
161 | 174 | issue.reload |
|
162 | 175 | assert_equal 'New ticket with custom field values', issue.subject |
|
163 | assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value | |
|
176 | assert_equal 'Value for a custom field', | |
|
177 | issue.custom_value_for(CustomField.find_by_name('Searchable field')).value | |
|
164 | 178 | assert !issue.description.match(/^searchable field:/i) |
|
165 | 179 | end |
|
166 | 180 | |
@@ -175,14 +189,22 class MailHandlerTest < ActiveSupport::TestCase | |||
|
175 | 189 | |
|
176 | 190 | def test_add_issue_by_unknown_user |
|
177 | 191 | assert_no_difference 'User.count' do |
|
178 | assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}) | |
|
192 | assert_equal false, | |
|
193 | submit_email( | |
|
194 | 'ticket_by_unknown_user.eml', | |
|
195 | :issue => {:project => 'ecookbook'} | |
|
196 | ) | |
|
179 | 197 | end |
|
180 | 198 | end |
|
181 | 199 | |
|
182 | 200 | def test_add_issue_by_anonymous_user |
|
183 | 201 | Role.anonymous.add_permission!(:add_issues) |
|
184 | 202 | assert_no_difference 'User.count' do |
|
185 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept') | |
|
203 | issue = submit_email( | |
|
204 | 'ticket_by_unknown_user.eml', | |
|
205 | :issue => {:project => 'ecookbook'}, | |
|
206 | :unknown_user => 'accept' | |
|
207 | ) | |
|
186 | 208 | assert issue.is_a?(Issue) |
|
187 | 209 | assert issue.author.anonymous? |
|
188 | 210 | end |
@@ -191,7 +213,11 class MailHandlerTest < ActiveSupport::TestCase | |||
|
191 | 213 | def test_add_issue_by_anonymous_user_with_no_from_address |
|
192 | 214 | Role.anonymous.add_permission!(:add_issues) |
|
193 | 215 | assert_no_difference 'User.count' do |
|
194 | issue = submit_email('ticket_by_empty_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept') | |
|
216 | issue = submit_email( | |
|
217 | 'ticket_by_empty_user.eml', | |
|
218 | :issue => {:project => 'ecookbook'}, | |
|
219 | :unknown_user => 'accept' | |
|
220 | ) | |
|
195 | 221 | assert issue.is_a?(Issue) |
|
196 | 222 | assert issue.author.anonymous? |
|
197 | 223 | end |
@@ -201,7 +227,12 class MailHandlerTest < ActiveSupport::TestCase | |||
|
201 | 227 | Role.anonymous.add_permission!(:add_issues) |
|
202 | 228 | assert_no_difference 'User.count' do |
|
203 | 229 | assert_no_difference 'Issue.count' do |
|
204 | assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'onlinestore'}, :unknown_user => 'accept') | |
|
230 | assert_equal false, | |
|
231 | submit_email( | |
|
232 | 'ticket_by_unknown_user.eml', | |
|
233 | :issue => {:project => 'onlinestore'}, | |
|
234 | :unknown_user => 'accept' | |
|
235 | ) | |
|
205 | 236 | end |
|
206 | 237 | end |
|
207 | 238 | end |
@@ -209,7 +240,12 class MailHandlerTest < ActiveSupport::TestCase | |||
|
209 | 240 | def test_add_issue_by_anonymous_user_on_private_project_without_permission_check |
|
210 | 241 | assert_no_difference 'User.count' do |
|
211 | 242 | assert_difference 'Issue.count' do |
|
212 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'onlinestore'}, :no_permission_check => '1', :unknown_user => 'accept') | |
|
243 | issue = submit_email( | |
|
244 | 'ticket_by_unknown_user.eml', | |
|
245 | :issue => {:project => 'onlinestore'}, | |
|
246 | :no_permission_check => '1', | |
|
247 | :unknown_user => 'accept' | |
|
248 | ) | |
|
213 | 249 | assert issue.is_a?(Issue) |
|
214 | 250 | assert issue.author.anonymous? |
|
215 | 251 | assert !issue.project.is_public? |
@@ -221,7 +257,11 class MailHandlerTest < ActiveSupport::TestCase | |||
|
221 | 257 | def test_add_issue_by_created_user |
|
222 | 258 | Setting.default_language = 'en' |
|
223 | 259 | assert_difference 'User.count' do |
|
224 | issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') | |
|
260 | issue = submit_email( | |
|
261 | 'ticket_by_unknown_user.eml', | |
|
262 | :issue => {:project => 'ecookbook'}, | |
|
263 | :unknown_user => 'create' | |
|
264 | ) | |
|
225 | 265 | assert issue.is_a?(Issue) |
|
226 | 266 | assert issue.author.active? |
|
227 | 267 | assert_equal 'john.doe@somenet.foo', issue.author.mail |
@@ -244,7 +284,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
244 | 284 | end |
|
245 | 285 | |
|
246 | 286 | def test_add_issue_with_invalid_attributes |
|
247 | issue = submit_email('ticket_with_invalid_attributes.eml', :allow_override => 'tracker,category,priority') | |
|
287 | issue = submit_email( | |
|
288 | 'ticket_with_invalid_attributes.eml', | |
|
289 | :allow_override => 'tracker,category,priority' | |
|
290 | ) | |
|
248 | 291 | assert issue.is_a?(Issue) |
|
249 | 292 | assert !issue.new_record? |
|
250 | 293 | issue.reload |
@@ -258,7 +301,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
258 | 301 | |
|
259 | 302 | def test_add_issue_with_localized_attributes |
|
260 | 303 | User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr' |
|
261 | issue = submit_email('ticket_with_localized_attributes.eml', :allow_override => 'tracker,category,priority') | |
|
304 | issue = submit_email( | |
|
305 | 'ticket_with_localized_attributes.eml', | |
|
306 | :allow_override => 'tracker,category,priority' | |
|
307 | ) | |
|
262 | 308 | assert issue.is_a?(Issue) |
|
263 | 309 | assert !issue.new_record? |
|
264 | 310 | issue.reload |
@@ -276,13 +322,20 class MailHandlerTest < ActiveSupport::TestCase | |||
|
276 | 322 | ja_dev.force_encoding('UTF-8') if ja_dev.respond_to?(:force_encoding) |
|
277 | 323 | tracker = Tracker.create!(:name => ja_dev) |
|
278 | 324 | Project.find(1).trackers << tracker |
|
279 | issue = submit_email('japanese_keywords_iso_2022_jp.eml', :issue => {:project => 'ecookbook'}, :allow_override => 'tracker') | |
|
325 | issue = submit_email( | |
|
326 | 'japanese_keywords_iso_2022_jp.eml', | |
|
327 | :issue => {:project => 'ecookbook'}, | |
|
328 | :allow_override => 'tracker' | |
|
329 | ) | |
|
280 | 330 | assert_kind_of Issue, issue |
|
281 | 331 | assert_equal tracker, issue.tracker |
|
282 | 332 | end |
|
283 | 333 | |
|
284 | 334 | def test_add_issue_from_apple_mail |
|
285 | issue = submit_email('apple_mail_with_attachment.eml', :issue => {:project => 'ecookbook'}) | |
|
335 | issue = submit_email( | |
|
336 | 'apple_mail_with_attachment.eml', | |
|
337 | :issue => {:project => 'ecookbook'} | |
|
338 | ) | |
|
286 | 339 | assert_kind_of Issue, issue |
|
287 | 340 | assert_equal 1, issue.attachments.size |
|
288 | 341 | |
@@ -297,7 +350,12 class MailHandlerTest < ActiveSupport::TestCase | |||
|
297 | 350 | def test_should_ignore_emails_from_emission_address |
|
298 | 351 | Role.anonymous.add_permission!(:add_issues) |
|
299 | 352 | assert_no_difference 'User.count' do |
|
300 | assert_equal false, submit_email('ticket_from_emission_address.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create') | |
|
353 | assert_equal false, | |
|
354 | submit_email( | |
|
355 | 'ticket_from_emission_address.eml', | |
|
356 | :issue => {:project => 'ecookbook'}, | |
|
357 | :unknown_user => 'create' | |
|
358 | ) | |
|
301 | 359 | end |
|
302 | 360 | end |
|
303 | 361 | |
@@ -367,7 +425,10 class MailHandlerTest < ActiveSupport::TestCase | |||
|
367 | 425 | end |
|
368 | 426 | |
|
369 | 427 | def test_update_issue_should_not_set_defaults |
|
370 | journal = submit_email('ticket_reply.eml', :issue => {:tracker => 'Support request', :priority => 'High'}) | |
|
428 | journal = submit_email( | |
|
429 | 'ticket_reply.eml', | |
|
430 | :issue => {:tracker => 'Support request', :priority => 'High'} | |
|
431 | ) | |
|
371 | 432 | assert journal.is_a?(Journal) |
|
372 | 433 | assert_match /This is reply/, journal.notes |
|
373 | 434 | assert_equal 'Feature request', journal.issue.tracker.name |
General Comments 0
You need to be logged in to leave comments.
Login now