23 |
23 |
fixtures :issues, :issue_statuses, :journals, :journal_details, :projects,
|
24 |
24 |
:projects_trackers, :trackers, :enabled_modules, :enumerations,
|
25 |
25 |
:users, :user_preferences, :email_addresses, :roles, :members, :member_roles,
|
26 |
|
:versions
|
|
26 |
:versions, :custom_fields, :custom_fields_trackers
|
27 |
27 |
|
28 |
28 |
def setup
|
29 |
29 |
User.current = nil
|
... | ... | |
194 |
194 |
issue.init_journal(user)
|
195 |
195 |
issue.fixed_version = versions(:versions_003)
|
196 |
196 |
|
|
197 |
assert issue.save
|
|
198 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
199 |
end
|
|
200 |
end
|
|
201 |
|
|
202 |
def test_create_should_send_email_notification_with_issue_start_date_updated
|
|
203 |
with_settings :notified_events => %w(issue_start_date_updated) do
|
|
204 |
user = User.find_by_login('jsmith')
|
|
205 |
issue = issues(:issues_001)
|
|
206 |
issue.init_journal(user)
|
|
207 |
issue.start_date = Date.current
|
|
208 |
|
|
209 |
assert issue.save
|
|
210 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
211 |
end
|
|
212 |
end
|
|
213 |
|
|
214 |
def test_create_should_not_send_email_notification_without_issue_start_date_updated
|
|
215 |
with_settings :notified_events => [] do
|
|
216 |
user = User.find_by_login('jsmith')
|
|
217 |
issue = issues(:issues_001)
|
|
218 |
issue.init_journal(user)
|
|
219 |
issue.start_date = Date.current
|
|
220 |
|
|
221 |
assert issue.save
|
|
222 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
223 |
end
|
|
224 |
end
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
def test_create_should_send_email_notification_with_issue_due_date_updated
|
|
229 |
with_settings :notified_events => %w(issue_due_date_updated) do
|
|
230 |
user = User.find_by_login('jsmith')
|
|
231 |
issue = issues(:issues_001)
|
|
232 |
issue.init_journal(user)
|
|
233 |
issue.due_date = Date.current
|
|
234 |
|
|
235 |
assert issue.save
|
|
236 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
237 |
end
|
|
238 |
end
|
|
239 |
|
|
240 |
def test_create_should_not_send_email_notification_without_issue_due_date_updated
|
|
241 |
with_settings :notified_events => [] do
|
|
242 |
user = User.find_by_login('jsmith')
|
|
243 |
issue = issues(:issues_001)
|
|
244 |
issue.init_journal(user)
|
|
245 |
issue.due_date = Date.current
|
|
246 |
|
|
247 |
assert issue.save
|
|
248 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
249 |
end
|
|
250 |
end
|
|
251 |
|
|
252 |
def test_create_should_send_email_notification_with_issue_estimated_hours_updated
|
|
253 |
with_settings :notified_events => %w(issue_estimated_hours_updated) do
|
|
254 |
user = User.find_by_login('jsmith')
|
|
255 |
issue = issues(:issues_001)
|
|
256 |
issue.init_journal(user)
|
|
257 |
issue.estimated_hours = '2h30'
|
|
258 |
|
|
259 |
assert issue.save
|
|
260 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
261 |
end
|
|
262 |
end
|
|
263 |
|
|
264 |
def test_create_should_not_send_email_notification_without_issue_estimated_hours_updated
|
|
265 |
with_settings :notified_events => [] do
|
|
266 |
user = User.find_by_login('jsmith')
|
|
267 |
issue = issues(:issues_001)
|
|
268 |
issue.init_journal(user)
|
|
269 |
issue.estimated_hours = '2h30'
|
|
270 |
|
|
271 |
assert issue.save
|
|
272 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
273 |
end
|
|
274 |
end
|
|
275 |
|
|
276 |
def test_create_should_send_email_notification_with_issue_category_updated
|
|
277 |
with_settings :notified_events => %w(issue_category_updated) do
|
|
278 |
user = User.find_by_login('jsmith')
|
|
279 |
issue = issues(:issues_001)
|
|
280 |
issue.init_journal(user)
|
|
281 |
issue.category_id = 2
|
|
282 |
|
|
283 |
assert issue.save
|
|
284 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
285 |
end
|
|
286 |
end
|
|
287 |
|
|
288 |
def test_create_should_not_send_email_notification_without_issue_category_updated
|
|
289 |
with_settings :notified_events => [] do
|
|
290 |
user = User.find_by_login('jsmith')
|
|
291 |
issue = issues(:issues_001)
|
|
292 |
issue.init_journal(user)
|
|
293 |
issue.category_id = 2
|
|
294 |
|
|
295 |
assert issue.save
|
|
296 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
297 |
end
|
|
298 |
end
|
|
299 |
|
|
300 |
def test_create_should_send_email_notification_with_issue_description_updated
|
|
301 |
with_settings :notified_events => %w(issue_description_updated) do
|
|
302 |
user = User.find_by_login('jsmith')
|
|
303 |
issue = issues(:issues_001)
|
|
304 |
issue.init_journal(user)
|
|
305 |
issue.description = 'description'
|
|
306 |
|
|
307 |
assert issue.save
|
|
308 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
309 |
end
|
|
310 |
end
|
|
311 |
|
|
312 |
def test_create_should_not_send_email_notification_without_issue_description_updated
|
|
313 |
with_settings :notified_events => [] do
|
|
314 |
user = User.find_by_login('jsmith')
|
|
315 |
issue = issues(:issues_001)
|
|
316 |
issue.init_journal(user)
|
|
317 |
issue.description = 'description'
|
|
318 |
|
|
319 |
assert issue.save
|
|
320 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
321 |
end
|
|
322 |
end
|
|
323 |
|
|
324 |
def test_create_should_send_email_notification_with_issue_done_ratio_updated
|
|
325 |
with_settings :notified_events => %w(issue_done_ratio_updated) do
|
|
326 |
user = User.find_by_login('jsmith')
|
|
327 |
issue = issues(:issues_001)
|
|
328 |
issue.init_journal(user)
|
|
329 |
issue.done_ratio = 30
|
|
330 |
|
|
331 |
assert issue.save
|
|
332 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
333 |
end
|
|
334 |
end
|
|
335 |
|
|
336 |
def test_create_should_not_send_email_notification_without_issue_done_ratio_updated
|
|
337 |
with_settings :notified_events => [] do
|
|
338 |
user = User.find_by_login('jsmith')
|
|
339 |
issue = issues(:issues_001)
|
|
340 |
issue.init_journal(user)
|
|
341 |
issue.done_ratio = 30
|
|
342 |
|
|
343 |
assert issue.save
|
|
344 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
345 |
end
|
|
346 |
end
|
|
347 |
|
|
348 |
def test_create_should_send_email_notification_with_issue_parent_updated
|
|
349 |
with_settings :notified_events => %w(issue_parent_updated) do
|
|
350 |
user = User.find_by_login('jsmith')
|
|
351 |
issue = issues(:issues_001)
|
|
352 |
issue.init_journal(user)
|
|
353 |
issue.parent = issues(:issues_002)
|
|
354 |
|
|
355 |
assert issue.save
|
|
356 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
357 |
end
|
|
358 |
end
|
|
359 |
|
|
360 |
def test_create_should_not_send_email_notification_without_issue_parent_updated
|
|
361 |
with_settings :notified_events => [] do
|
|
362 |
user = User.find_by_login('jsmith')
|
|
363 |
issue = issues(:issues_001)
|
|
364 |
issue.init_journal(user)
|
|
365 |
issue.parent = issues(:issues_002)
|
|
366 |
|
|
367 |
assert issue.save
|
|
368 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
369 |
end
|
|
370 |
end
|
|
371 |
|
|
372 |
def test_create_should_send_email_notification_with_issue_project_updated
|
|
373 |
with_settings :notified_events => %w(issue_project_updated) do
|
|
374 |
user = User.find_by_login('jsmith')
|
|
375 |
issue = issues(:issues_001)
|
|
376 |
issue.init_journal(user)
|
|
377 |
issue.project = projects(:projects_002)
|
|
378 |
|
|
379 |
assert issue.save
|
|
380 |
# Dave is not a member of project
|
|
381 |
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
382 |
end
|
|
383 |
end
|
|
384 |
|
|
385 |
def test_create_should_not_send_email_notification_without_issue_project_updated
|
|
386 |
with_settings :notified_events => [] do
|
|
387 |
user = User.find_by_login('jsmith')
|
|
388 |
issue = issues(:issues_001)
|
|
389 |
issue.init_journal(user)
|
|
390 |
issue.project = projects(:projects_002)
|
|
391 |
|
|
392 |
assert issue.save
|
|
393 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
394 |
end
|
|
395 |
end
|
|
396 |
|
|
397 |
def test_create_should_send_email_notification_with_issue_tracker_updated
|
|
398 |
with_settings :notified_events => %w(issue_tracker_updated) do
|
|
399 |
user = User.find_by_login('jsmith')
|
|
400 |
issue = issues(:issues_001)
|
|
401 |
issue.init_journal(user)
|
|
402 |
issue.tracker = trackers(:trackers_002)
|
|
403 |
|
|
404 |
assert issue.save
|
|
405 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
406 |
end
|
|
407 |
end
|
|
408 |
|
|
409 |
def test_create_should_not_send_email_notification_without_issue_tracker_updated
|
|
410 |
with_settings :notified_events => [] do
|
|
411 |
user = User.find_by_login('jsmith')
|
|
412 |
issue = issues(:issues_001)
|
|
413 |
issue.init_journal(user)
|
|
414 |
issue.tracker = trackers(:trackers_002)
|
|
415 |
|
|
416 |
assert issue.save
|
|
417 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
418 |
end
|
|
419 |
end
|
|
420 |
|
|
421 |
def test_create_should_send_email_notification_with_issue_subject_updated
|
|
422 |
with_settings :notified_events => %w(issue_subject_updated) do
|
|
423 |
user = User.find_by_login('jsmith')
|
|
424 |
issue = issues(:issues_001)
|
|
425 |
issue.init_journal(user)
|
|
426 |
issue.subject = Time.current.to_s
|
|
427 |
|
|
428 |
assert issue.save
|
|
429 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
430 |
end
|
|
431 |
end
|
|
432 |
|
|
433 |
def test_create_should_not_send_email_notification_without_issue_subject_updated
|
|
434 |
with_settings :notified_events => [] do
|
|
435 |
user = User.find_by_login('jsmith')
|
|
436 |
issue = issues(:issues_001)
|
|
437 |
issue.init_journal(user)
|
|
438 |
issue.subject = Time.current.to_s
|
|
439 |
|
|
440 |
assert issue.save
|
|
441 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
442 |
end
|
|
443 |
end
|
|
444 |
|
|
445 |
def test_create_should_send_email_notification_with_issue_attachment_updated
|
|
446 |
with_settings :notified_events => %w(issue_attachment_updated) do
|
|
447 |
user = User.find_by_login('jsmith')
|
|
448 |
issue = issues(:issues_001)
|
|
449 |
issue.init_journal(user)
|
|
450 |
issue.save_attachments('1' => {'file' => mock_file_with_options(:original_filename => 'test.png')})
|
|
451 |
issue.attach_saved_attachments
|
|
452 |
|
|
453 |
assert issue.save
|
|
454 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
455 |
end
|
|
456 |
end
|
|
457 |
|
|
458 |
def test_create_should_not_send_email_notification_without_issue_attachment_updated
|
|
459 |
with_settings :notified_events => [] do
|
|
460 |
user = User.find_by_login('jsmith')
|
|
461 |
issue = issues(:issues_001)
|
|
462 |
issue.init_journal(user)
|
|
463 |
issue.save_attachments('1' => {'file' => mock_file_with_options(:original_filename => 'test.png')})
|
|
464 |
issue.attach_saved_attachments
|
|
465 |
|
|
466 |
assert issue.save
|
|
467 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
468 |
end
|
|
469 |
end
|
|
470 |
|
|
471 |
def test_create_should_send_email_notification_with_issue_relation_updated
|
|
472 |
with_settings :notified_events => %w(issue_relation_updated) do
|
|
473 |
user = User.find_by_login('jsmith')
|
|
474 |
issue = issues(:issues_001)
|
|
475 |
rel = IssueRelation.new(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
|
|
476 |
rel.init_journals(user)
|
|
477 |
rel.save
|
|
478 |
|
|
479 |
# relation updated two issues #1 and #3
|
|
480 |
assert issue.save
|
|
481 |
assert_equal 4, ActionMailer::Base.deliveries.size
|
|
482 |
end
|
|
483 |
end
|
|
484 |
|
|
485 |
def test_create_should_not_send_email_notification_without_issue_relation_updated
|
|
486 |
with_settings :notified_events => [] do
|
|
487 |
user = User.find_by_login('jsmith')
|
|
488 |
issue = issues(:issues_001)
|
|
489 |
rel = IssueRelation.new(:relation_type => "relates", :issue_from => Issue.find(3), :issue_to => Issue.find(1))
|
|
490 |
rel.init_journals(user)
|
|
491 |
rel.save
|
|
492 |
|
|
493 |
assert issue.save
|
|
494 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
495 |
end
|
|
496 |
end
|
|
497 |
|
|
498 |
def test_create_should_send_email_notification_with_issue_custom_value_updated
|
|
499 |
with_settings :notified_events => %w(issue_custom_value_updated) do
|
|
500 |
user = User.find_by_login('jsmith')
|
|
501 |
issue = issues(:issues_001)
|
|
502 |
issue.init_journal(user)
|
|
503 |
issue.custom_field_values = {'2' => 'some value'}
|
|
504 |
|
|
505 |
assert issue.save
|
|
506 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
507 |
end
|
|
508 |
end
|
|
509 |
|
|
510 |
def test_create_should_not_send_email_notification_without_custom_value_updated
|
|
511 |
with_settings :notified_events => [] do
|
|
512 |
user = User.find_by_login('jsmith')
|
|
513 |
issue = issues(:issues_001)
|
|
514 |
issue.init_journal(user)
|
|
515 |
issue.custom_field_values = {'2' => 'some value'}
|
|
516 |
|
197 |
517 |
assert issue.save
|
198 |
518 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
199 |
519 |
end
|