To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / unit / journal_observer_test.rb @ 441:cbce1fd3b1b7
History | View | Annotate | Download (4.19 KB)
| 1 | 441:cbce1fd3b1b7 | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang
|
||
| 3 | 37:94944d00e43c | chris | #
|
| 4 | # This program is free software; you can redistribute it and/or
|
||
| 5 | # modify it under the terms of the GNU General Public License
|
||
| 6 | # as published by the Free Software Foundation; either version 2
|
||
| 7 | # of the License, or (at your option) any later version.
|
||
| 8 | 441:cbce1fd3b1b7 | Chris | #
|
| 9 | 37:94944d00e43c | chris | # This program is distributed in the hope that it will be useful,
|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 12 | # GNU General Public License for more details.
|
||
| 13 | 441:cbce1fd3b1b7 | Chris | #
|
| 14 | 37:94944d00e43c | chris | # You should have received a copy of the GNU General Public License
|
| 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.
|
||
| 17 | |||
| 18 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__) |
| 19 | 37:94944d00e43c | chris | |
| 20 | class JournalObserverTest < ActiveSupport::TestCase |
||
| 21 | fixtures :issues, :issue_statuses, :journals, :journal_details |
||
| 22 | |||
| 23 | def setup |
||
| 24 | ActionMailer::Base.deliveries.clear |
||
| 25 | @journal = Journal.find 1 |
||
| 26 | end
|
||
| 27 | |||
| 28 | # context: issue_updated notified_events
|
||
| 29 | def test_create_should_send_email_notification_with_issue_updated |
||
| 30 | Setting.notified_events = ['issue_updated'] |
||
| 31 | issue = Issue.find(:first) |
||
| 32 | user = User.find(:first) |
||
| 33 | journal = issue.init_journal(user, issue) |
||
| 34 | |||
| 35 | assert journal.save |
||
| 36 | assert_equal 1, ActionMailer::Base.deliveries.size |
||
| 37 | end
|
||
| 38 | |||
| 39 | 441:cbce1fd3b1b7 | Chris | def test_create_should_not_send_email_notification_with_notify_set_to_false |
| 40 | Setting.notified_events = ['issue_updated'] |
||
| 41 | issue = Issue.find(:first) |
||
| 42 | user = User.find(:first) |
||
| 43 | journal = issue.init_journal(user, issue) |
||
| 44 | journal.notify = false
|
||
| 45 | |||
| 46 | assert journal.save |
||
| 47 | assert_equal 0, ActionMailer::Base.deliveries.size |
||
| 48 | end
|
||
| 49 | |||
| 50 | 37:94944d00e43c | chris | def test_create_should_not_send_email_notification_without_issue_updated |
| 51 | Setting.notified_events = []
|
||
| 52 | issue = Issue.find(:first) |
||
| 53 | user = User.find(:first) |
||
| 54 | journal = issue.init_journal(user, issue) |
||
| 55 | |||
| 56 | assert journal.save |
||
| 57 | assert_equal 0, ActionMailer::Base.deliveries.size |
||
| 58 | end
|
||
| 59 | |||
| 60 | # context: issue_note_added notified_events
|
||
| 61 | def test_create_should_send_email_notification_with_issue_note_added |
||
| 62 | Setting.notified_events = ['issue_note_added'] |
||
| 63 | issue = Issue.find(:first) |
||
| 64 | user = User.find(:first) |
||
| 65 | journal = issue.init_journal(user, issue) |
||
| 66 | journal.notes = 'This update has a note'
|
||
| 67 | |||
| 68 | assert journal.save |
||
| 69 | assert_equal 1, ActionMailer::Base.deliveries.size |
||
| 70 | end
|
||
| 71 | |||
| 72 | def test_create_should_not_send_email_notification_without_issue_note_added |
||
| 73 | Setting.notified_events = []
|
||
| 74 | issue = Issue.find(:first) |
||
| 75 | user = User.find(:first) |
||
| 76 | journal = issue.init_journal(user, issue) |
||
| 77 | journal.notes = 'This update has a note'
|
||
| 78 | 441:cbce1fd3b1b7 | Chris | |
| 79 | 37:94944d00e43c | chris | assert journal.save |
| 80 | assert_equal 0, ActionMailer::Base.deliveries.size |
||
| 81 | end
|
||
| 82 | |||
| 83 | # context: issue_status_updated notified_events
|
||
| 84 | def test_create_should_send_email_notification_with_issue_status_updated |
||
| 85 | Setting.notified_events = ['issue_status_updated'] |
||
| 86 | issue = Issue.find(:first) |
||
| 87 | user = User.find(:first) |
||
| 88 | issue.init_journal(user, issue) |
||
| 89 | issue.status = IssueStatus.last
|
||
| 90 | |||
| 91 | assert issue.save |
||
| 92 | assert_equal 1, ActionMailer::Base.deliveries.size |
||
| 93 | end
|
||
| 94 | |||
| 95 | def test_create_should_not_send_email_notification_without_issue_status_updated |
||
| 96 | Setting.notified_events = []
|
||
| 97 | issue = Issue.find(:first) |
||
| 98 | user = User.find(:first) |
||
| 99 | issue.init_journal(user, issue) |
||
| 100 | issue.status = IssueStatus.last
|
||
| 101 | 441:cbce1fd3b1b7 | Chris | |
| 102 | 37:94944d00e43c | chris | assert issue.save |
| 103 | assert_equal 0, ActionMailer::Base.deliveries.size |
||
| 104 | end
|
||
| 105 | |||
| 106 | # context: issue_priority_updated notified_events
|
||
| 107 | def test_create_should_send_email_notification_with_issue_priority_updated |
||
| 108 | Setting.notified_events = ['issue_priority_updated'] |
||
| 109 | issue = Issue.find(:first) |
||
| 110 | user = User.find(:first) |
||
| 111 | issue.init_journal(user, issue) |
||
| 112 | issue.priority = IssuePriority.last
|
||
| 113 | |||
| 114 | assert issue.save |
||
| 115 | assert_equal 1, ActionMailer::Base.deliveries.size |
||
| 116 | end
|
||
| 117 | |||
| 118 | def test_create_should_not_send_email_notification_without_issue_priority_updated |
||
| 119 | Setting.notified_events = []
|
||
| 120 | issue = Issue.find(:first) |
||
| 121 | user = User.find(:first) |
||
| 122 | issue.init_journal(user, issue) |
||
| 123 | issue.priority = IssuePriority.last
|
||
| 124 | 441:cbce1fd3b1b7 | Chris | |
| 125 | 37:94944d00e43c | chris | assert issue.save |
| 126 | assert_equal 0, ActionMailer::Base.deliveries.size |
||
| 127 | end
|
||
| 128 | end |