Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/journal_observer_test.rb.svn-base @ 37:94944d00e43c
* Update to SVN trunk rev 4411
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 19 Nov 2010 13:24:41 +0000 |
parents | |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
22:40f7cfd4df19 | 37:94944d00e43c |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | |
3 # | |
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 # | |
9 # 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 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.dirname(__FILE__) + '/../test_helper' | |
19 | |
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 def test_create_should_not_send_email_notification_without_issue_updated | |
40 Setting.notified_events = [] | |
41 issue = Issue.find(:first) | |
42 user = User.find(:first) | |
43 journal = issue.init_journal(user, issue) | |
44 | |
45 assert journal.save | |
46 assert_equal 0, ActionMailer::Base.deliveries.size | |
47 end | |
48 | |
49 # context: issue_note_added notified_events | |
50 def test_create_should_send_email_notification_with_issue_note_added | |
51 Setting.notified_events = ['issue_note_added'] | |
52 issue = Issue.find(:first) | |
53 user = User.find(:first) | |
54 journal = issue.init_journal(user, issue) | |
55 journal.notes = 'This update has a note' | |
56 | |
57 assert journal.save | |
58 assert_equal 1, ActionMailer::Base.deliveries.size | |
59 end | |
60 | |
61 def test_create_should_not_send_email_notification_without_issue_note_added | |
62 Setting.notified_events = [] | |
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 0, ActionMailer::Base.deliveries.size | |
70 end | |
71 | |
72 # context: issue_status_updated notified_events | |
73 def test_create_should_send_email_notification_with_issue_status_updated | |
74 Setting.notified_events = ['issue_status_updated'] | |
75 issue = Issue.find(:first) | |
76 user = User.find(:first) | |
77 issue.init_journal(user, issue) | |
78 issue.status = IssueStatus.last | |
79 | |
80 assert issue.save | |
81 assert_equal 1, ActionMailer::Base.deliveries.size | |
82 end | |
83 | |
84 def test_create_should_not_send_email_notification_without_issue_status_updated | |
85 Setting.notified_events = [] | |
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 0, ActionMailer::Base.deliveries.size | |
93 end | |
94 | |
95 # context: issue_priority_updated notified_events | |
96 def test_create_should_send_email_notification_with_issue_priority_updated | |
97 Setting.notified_events = ['issue_priority_updated'] | |
98 issue = Issue.find(:first) | |
99 user = User.find(:first) | |
100 issue.init_journal(user, issue) | |
101 issue.priority = IssuePriority.last | |
102 | |
103 assert issue.save | |
104 assert_equal 1, ActionMailer::Base.deliveries.size | |
105 end | |
106 | |
107 def test_create_should_not_send_email_notification_without_issue_priority_updated | |
108 Setting.notified_events = [] | |
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 0, ActionMailer::Base.deliveries.size | |
116 end | |
117 | |
118 end |