comparison .svn/pristine/f7/f78ddc144c31f10580290509649e50dda2f4e570.svn-base @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 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.expand_path('../../test_helper', __FILE__)
19
20 class JournalObserverTest < ActiveSupport::TestCase
21 fixtures :issues, :issue_statuses, :journals, :journal_details, :projects,
22 :projects_trackers, :trackers, :enabled_modules, :enumerations,
23 :users, :roles
24
25 def setup
26 ActionMailer::Base.deliveries.clear
27 @journal = Journal.find 1
28 end
29
30 # context: issue_updated notified_events
31 def test_create_should_send_email_notification_with_issue_updated
32 issue = Issue.first
33 user = User.first
34 journal = issue.init_journal(user, issue)
35
36 with_settings :notified_events => %w(issue_updated) do
37 assert journal.save
38 end
39 assert_equal 1, ActionMailer::Base.deliveries.size
40 end
41
42 def test_create_should_not_send_email_notification_with_notify_set_to_false
43 issue = Issue.first
44 user = User.first
45 journal = issue.init_journal(user, issue)
46 journal.notify = false
47
48 with_settings :notified_events => %w(issue_updated) do
49 assert journal.save
50 end
51 assert_equal 0, ActionMailer::Base.deliveries.size
52 end
53
54 def test_create_should_not_send_email_notification_without_issue_updated
55 issue = Issue.first
56 user = User.first
57 journal = issue.init_journal(user, issue)
58
59 with_settings :notified_events => [] do
60 assert journal.save
61 end
62 assert_equal 0, ActionMailer::Base.deliveries.size
63 end
64
65 # context: issue_note_added notified_events
66 def test_create_should_send_email_notification_with_issue_note_added
67 issue = Issue.first
68 user = User.first
69 journal = issue.init_journal(user, issue)
70 journal.notes = 'This update has a note'
71
72 with_settings :notified_events => %w(issue_note_added) do
73 assert journal.save
74 end
75 assert_equal 1, ActionMailer::Base.deliveries.size
76 end
77
78 def test_create_should_not_send_email_notification_without_issue_note_added
79 issue = Issue.first
80 user = User.first
81 journal = issue.init_journal(user, issue)
82 journal.notes = 'This update has a note'
83
84 with_settings :notified_events => [] do
85 assert journal.save
86 end
87 assert_equal 0, ActionMailer::Base.deliveries.size
88 end
89
90 # context: issue_status_updated notified_events
91 def test_create_should_send_email_notification_with_issue_status_updated
92 issue = Issue.first
93 user = User.first
94 issue.init_journal(user, issue)
95 issue.status = IssueStatus.last
96
97 with_settings :notified_events => %w(issue_status_updated) do
98 assert issue.save
99 end
100 assert_equal 1, ActionMailer::Base.deliveries.size
101 end
102
103 def test_create_should_not_send_email_notification_without_issue_status_updated
104 issue = Issue.first
105 user = User.first
106 issue.init_journal(user, issue)
107 issue.status = IssueStatus.last
108
109 with_settings :notified_events => [] do
110 assert issue.save
111 end
112 assert_equal 0, ActionMailer::Base.deliveries.size
113 end
114
115 # context: issue_priority_updated notified_events
116 def test_create_should_send_email_notification_with_issue_priority_updated
117 issue = Issue.first
118 user = User.first
119 issue.init_journal(user, issue)
120 issue.priority = IssuePriority.last
121
122 with_settings :notified_events => %w(issue_priority_updated) do
123 assert issue.save
124 end
125 assert_equal 1, ActionMailer::Base.deliveries.size
126 end
127
128 def test_create_should_not_send_email_notification_without_issue_priority_updated
129 issue = Issue.first
130 user = User.first
131 issue.init_journal(user, issue)
132 issue.priority = IssuePriority.last
133
134 with_settings :notified_events => [] do
135 assert issue.save
136 end
137 assert_equal 0, ActionMailer::Base.deliveries.size
138 end
139 end