Mercurial > hg > soundsoftware-site
comparison test/unit/journal_observer_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
27 @journal = Journal.find 1 | 27 @journal = Journal.find 1 |
28 end | 28 end |
29 | 29 |
30 # context: issue_updated notified_events | 30 # context: issue_updated notified_events |
31 def test_create_should_send_email_notification_with_issue_updated | 31 def test_create_should_send_email_notification_with_issue_updated |
32 issue = Issue.find(:first) | 32 issue = Issue.first |
33 user = User.find(:first) | 33 user = User.first |
34 journal = issue.init_journal(user, issue) | 34 journal = issue.init_journal(user, issue) |
35 | 35 |
36 with_settings :notified_events => %w(issue_updated) do | 36 with_settings :notified_events => %w(issue_updated) do |
37 assert journal.save | 37 assert journal.save |
38 end | 38 end |
39 assert_equal 1, ActionMailer::Base.deliveries.size | 39 assert_equal 1, ActionMailer::Base.deliveries.size |
40 end | 40 end |
41 | 41 |
42 def test_create_should_not_send_email_notification_with_notify_set_to_false | 42 def test_create_should_not_send_email_notification_with_notify_set_to_false |
43 issue = Issue.find(:first) | 43 issue = Issue.first |
44 user = User.find(:first) | 44 user = User.first |
45 journal = issue.init_journal(user, issue) | 45 journal = issue.init_journal(user, issue) |
46 journal.notify = false | 46 journal.notify = false |
47 | 47 |
48 with_settings :notified_events => %w(issue_updated) do | 48 with_settings :notified_events => %w(issue_updated) do |
49 assert journal.save | 49 assert journal.save |
50 end | 50 end |
51 assert_equal 0, ActionMailer::Base.deliveries.size | 51 assert_equal 0, ActionMailer::Base.deliveries.size |
52 end | 52 end |
53 | 53 |
54 def test_create_should_not_send_email_notification_without_issue_updated | 54 def test_create_should_not_send_email_notification_without_issue_updated |
55 issue = Issue.find(:first) | 55 issue = Issue.first |
56 user = User.find(:first) | 56 user = User.first |
57 journal = issue.init_journal(user, issue) | 57 journal = issue.init_journal(user, issue) |
58 | 58 |
59 with_settings :notified_events => [] do | 59 with_settings :notified_events => [] do |
60 assert journal.save | 60 assert journal.save |
61 end | 61 end |
62 assert_equal 0, ActionMailer::Base.deliveries.size | 62 assert_equal 0, ActionMailer::Base.deliveries.size |
63 end | 63 end |
64 | 64 |
65 # context: issue_note_added notified_events | 65 # context: issue_note_added notified_events |
66 def test_create_should_send_email_notification_with_issue_note_added | 66 def test_create_should_send_email_notification_with_issue_note_added |
67 issue = Issue.find(:first) | 67 issue = Issue.first |
68 user = User.find(:first) | 68 user = User.first |
69 journal = issue.init_journal(user, issue) | 69 journal = issue.init_journal(user, issue) |
70 journal.notes = 'This update has a note' | 70 journal.notes = 'This update has a note' |
71 | 71 |
72 with_settings :notified_events => %w(issue_note_added) do | 72 with_settings :notified_events => %w(issue_note_added) do |
73 assert journal.save | 73 assert journal.save |
74 end | 74 end |
75 assert_equal 1, ActionMailer::Base.deliveries.size | 75 assert_equal 1, ActionMailer::Base.deliveries.size |
76 end | 76 end |
77 | 77 |
78 def test_create_should_not_send_email_notification_without_issue_note_added | 78 def test_create_should_not_send_email_notification_without_issue_note_added |
79 issue = Issue.find(:first) | 79 issue = Issue.first |
80 user = User.find(:first) | 80 user = User.first |
81 journal = issue.init_journal(user, issue) | 81 journal = issue.init_journal(user, issue) |
82 journal.notes = 'This update has a note' | 82 journal.notes = 'This update has a note' |
83 | 83 |
84 with_settings :notified_events => [] do | 84 with_settings :notified_events => [] do |
85 assert journal.save | 85 assert journal.save |
87 assert_equal 0, ActionMailer::Base.deliveries.size | 87 assert_equal 0, ActionMailer::Base.deliveries.size |
88 end | 88 end |
89 | 89 |
90 # context: issue_status_updated notified_events | 90 # context: issue_status_updated notified_events |
91 def test_create_should_send_email_notification_with_issue_status_updated | 91 def test_create_should_send_email_notification_with_issue_status_updated |
92 issue = Issue.find(:first) | 92 issue = Issue.first |
93 user = User.find(:first) | 93 user = User.first |
94 issue.init_journal(user, issue) | 94 issue.init_journal(user, issue) |
95 issue.status = IssueStatus.last | 95 issue.status = IssueStatus.last |
96 | 96 |
97 with_settings :notified_events => %w(issue_status_updated) do | 97 with_settings :notified_events => %w(issue_status_updated) do |
98 assert issue.save | 98 assert issue.save |
99 end | 99 end |
100 assert_equal 1, ActionMailer::Base.deliveries.size | 100 assert_equal 1, ActionMailer::Base.deliveries.size |
101 end | 101 end |
102 | 102 |
103 def test_create_should_not_send_email_notification_without_issue_status_updated | 103 def test_create_should_not_send_email_notification_without_issue_status_updated |
104 issue = Issue.find(:first) | 104 issue = Issue.first |
105 user = User.find(:first) | 105 user = User.first |
106 issue.init_journal(user, issue) | 106 issue.init_journal(user, issue) |
107 issue.status = IssueStatus.last | 107 issue.status = IssueStatus.last |
108 | 108 |
109 with_settings :notified_events => [] do | 109 with_settings :notified_events => [] do |
110 assert issue.save | 110 assert issue.save |
112 assert_equal 0, ActionMailer::Base.deliveries.size | 112 assert_equal 0, ActionMailer::Base.deliveries.size |
113 end | 113 end |
114 | 114 |
115 # context: issue_priority_updated notified_events | 115 # context: issue_priority_updated notified_events |
116 def test_create_should_send_email_notification_with_issue_priority_updated | 116 def test_create_should_send_email_notification_with_issue_priority_updated |
117 issue = Issue.find(:first) | 117 issue = Issue.first |
118 user = User.find(:first) | 118 user = User.first |
119 issue.init_journal(user, issue) | 119 issue.init_journal(user, issue) |
120 issue.priority = IssuePriority.last | 120 issue.priority = IssuePriority.last |
121 | 121 |
122 with_settings :notified_events => %w(issue_priority_updated) do | 122 with_settings :notified_events => %w(issue_priority_updated) do |
123 assert issue.save | 123 assert issue.save |
124 end | 124 end |
125 assert_equal 1, ActionMailer::Base.deliveries.size | 125 assert_equal 1, ActionMailer::Base.deliveries.size |
126 end | 126 end |
127 | 127 |
128 def test_create_should_not_send_email_notification_without_issue_priority_updated | 128 def test_create_should_not_send_email_notification_without_issue_priority_updated |
129 issue = Issue.find(:first) | 129 issue = Issue.first |
130 user = User.find(:first) | 130 user = User.first |
131 issue.init_journal(user, issue) | 131 issue.init_journal(user, issue) |
132 issue.priority = IssuePriority.last | 132 issue.priority = IssuePriority.last |
133 | 133 |
134 with_settings :notified_events => [] do | 134 with_settings :notified_events => [] do |
135 assert issue.save | 135 assert issue.save |