| 84 |
84 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 85 |
85 |
end
|
| 86 |
86 |
|
| 87 |
|
def test_create_should_send_email_notification_with_issue_status_updated
|
|
87 |
def test_create_should_send_email_notification_with_issue_attr_updated_details_status
|
| 88 |
88 |
issue = Issue.first
|
| 89 |
89 |
user = User.first
|
| 90 |
90 |
issue.init_journal(user)
|
| 91 |
91 |
issue.status = IssueStatus.last
|
| 92 |
92 |
|
| 93 |
|
with_settings :notified_events => %w(issue_status_updated) do
|
|
93 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => %w(status_id)) do
|
| 94 |
94 |
assert issue.save
|
| 95 |
95 |
end
|
| 96 |
96 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
| 97 |
97 |
end
|
| 98 |
98 |
|
| 99 |
|
def test_create_should_not_send_email_notification_without_issue_status_updated
|
|
99 |
def test_create_should_send_email_notification_with_issue_attr_updated
|
| 100 |
100 |
issue = Issue.first
|
| 101 |
101 |
user = User.first
|
| 102 |
102 |
issue.init_journal(user)
|
| 103 |
103 |
issue.status = IssueStatus.last
|
| 104 |
104 |
|
| 105 |
|
with_settings :notified_events => [] do
|
|
105 |
with_settings(:notified_events => %w(issue_attr_updated), :notified_event_issue_attr_updated_details => []) do
|
|
106 |
assert issue.save
|
|
107 |
end
|
|
108 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
109 |
end
|
|
110 |
|
|
111 |
def test_create_should_not_send_email_notification_without_issue_attr_updated_details_status
|
|
112 |
issue = Issue.first
|
|
113 |
user = User.first
|
|
114 |
issue.init_journal(user)
|
|
115 |
issue.status = IssueStatus.last
|
|
116 |
|
|
117 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => []) do
|
| 106 |
118 |
assert issue.save
|
| 107 |
119 |
end
|
| 108 |
120 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 109 |
121 |
end
|
| 110 |
122 |
|
| 111 |
|
def test_create_without_status_update_should_not_send_email_notification_with_issue_status_updated
|
|
123 |
def test_create_without_status_update_should_not_send_email_notification_with_issue_attr_updated_details_status
|
| 112 |
124 |
issue = Issue.first
|
| 113 |
125 |
user = User.first
|
| 114 |
126 |
issue.init_journal(user)
|
| 115 |
127 |
issue.subject = "No status update"
|
| 116 |
128 |
|
| 117 |
|
with_settings :notified_events => %w(issue_status_updated) do
|
|
129 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => %w(status_id)) do
|
| 118 |
130 |
assert issue.save
|
| 119 |
131 |
end
|
| 120 |
132 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 121 |
133 |
end
|
| 122 |
134 |
|
| 123 |
|
def test_create_should_send_email_notification_with_issue_assignee_updated
|
|
135 |
def test_create_should_send_email_notification_with_issue_attr_updated_details_assignee
|
| 124 |
136 |
issue = Issue.generate!(:assigned_to_id => 2)
|
| 125 |
137 |
ActionMailer::Base.deliveries.clear
|
| 126 |
138 |
user = User.first
|
| 127 |
139 |
issue.init_journal(user)
|
| 128 |
140 |
issue.assigned_to = User.find(3)
|
| 129 |
141 |
|
| 130 |
|
with_settings :notified_events => %w(issue_assigned_to_updated) do
|
|
142 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => %w(assigned_to_id)) do
|
| 131 |
143 |
assert issue.save
|
| 132 |
144 |
end
|
| 133 |
145 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
| 134 |
146 |
end
|
| 135 |
147 |
|
| 136 |
|
def test_create_should_not_send_email_notification_without_issue_assignee_updated
|
|
148 |
def test_create_should_send_email_notification_with_issue_attr_updated_assignee
|
| 137 |
149 |
issue = Issue.generate!(:assigned_to_id => 2)
|
| 138 |
150 |
ActionMailer::Base.deliveries.clear
|
| 139 |
151 |
user = User.first
|
| 140 |
152 |
issue.init_journal(user)
|
| 141 |
153 |
issue.assigned_to = User.find(3)
|
| 142 |
154 |
|
| 143 |
|
with_settings :notified_events => [] do
|
|
155 |
with_settings(:notified_events => %w(issue_attr_updated), :notified_event_issue_attr_updated_details => []) do
|
|
156 |
assert issue.save
|
|
157 |
end
|
|
158 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
159 |
end
|
|
160 |
|
|
161 |
def test_create_should_not_send_email_notification_without_issue_attr_updated_details_assignee
|
|
162 |
issue = Issue.generate!(:assigned_to_id => 2)
|
|
163 |
ActionMailer::Base.deliveries.clear
|
|
164 |
user = User.first
|
|
165 |
issue.init_journal(user)
|
|
166 |
issue.assigned_to = User.find(3)
|
|
167 |
|
|
168 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => []) do
|
| 144 |
169 |
assert issue.save
|
| 145 |
170 |
end
|
| 146 |
171 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 147 |
172 |
end
|
| 148 |
173 |
|
| 149 |
|
def test_create_should_send_email_notification_with_issue_priority_updated
|
|
174 |
def test_create_should_send_email_notification_with_issue_attr_updated_details_priority
|
| 150 |
175 |
issue = Issue.first
|
| 151 |
176 |
user = User.first
|
| 152 |
177 |
issue.init_journal(user)
|
| 153 |
178 |
issue.priority = IssuePriority.last
|
| 154 |
179 |
|
| 155 |
|
with_settings :notified_events => %w(issue_priority_updated) do
|
|
180 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => %w(priority_id)) do
|
| 156 |
181 |
assert issue.save
|
| 157 |
182 |
end
|
| 158 |
183 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
| 159 |
184 |
end
|
| 160 |
185 |
|
| 161 |
|
def test_create_should_not_send_email_notification_without_issue_priority_updated
|
|
186 |
def test_create_should_send_email_notification_with_issue_attr_updated_priority
|
| 162 |
187 |
issue = Issue.first
|
| 163 |
188 |
user = User.first
|
| 164 |
189 |
issue.init_journal(user)
|
| 165 |
190 |
issue.priority = IssuePriority.last
|
| 166 |
191 |
|
| 167 |
|
with_settings :notified_events => [] do
|
|
192 |
with_settings(:notified_events => %w(issue_attr_updated), :notified_event_issue_attr_updated_details => []) do
|
|
193 |
assert issue.save
|
|
194 |
end
|
|
195 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
196 |
end
|
|
197 |
|
|
198 |
def test_create_should_not_send_email_notification_without_issue_attr_updated_details_priority
|
|
199 |
issue = Issue.first
|
|
200 |
user = User.first
|
|
201 |
issue.init_journal(user)
|
|
202 |
issue.priority = IssuePriority.last
|
|
203 |
|
|
204 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => []) do
|
| 168 |
205 |
assert issue.save
|
| 169 |
206 |
end
|
| 170 |
207 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 171 |
208 |
end
|
| 172 |
209 |
|
| 173 |
|
def test_create_should_send_email_notification_with_issue_fixed_version_updated
|
| 174 |
|
with_settings :notified_events => %w(issue_fixed_version_updated) do
|
|
210 |
def test_create_should_send_email_notification_with_issue_attr_updated_details_fixed_version
|
|
211 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => %w(fixed_version_id)) do
|
| 175 |
212 |
user = User.find_by_login('jsmith')
|
| 176 |
213 |
issue = issues(:issues_001)
|
| 177 |
214 |
issue.init_journal(user)
|
| ... | ... | |
| 182 |
219 |
end
|
| 183 |
220 |
end
|
| 184 |
221 |
|
| 185 |
|
def test_create_should_not_send_email_notification_without_issue_fixed_version_updated
|
| 186 |
|
with_settings :notified_events => [] do
|
|
222 |
def test_create_should_send_email_notification_with_issue_attr_updated_fixed_version
|
|
223 |
with_settings(:notified_events => %w(issue_attr_updated), :notified_event_issue_attr_updated_details => []) do
|
|
224 |
user = User.find_by_login('jsmith')
|
|
225 |
issue = issues(:issues_001)
|
|
226 |
issue.init_journal(user)
|
|
227 |
issue.fixed_version = versions(:versions_003)
|
|
228 |
|
|
229 |
assert issue.save
|
|
230 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
231 |
end
|
|
232 |
end
|
|
233 |
|
|
234 |
def test_create_should_not_send_email_notification_without_issue_attr_updated_details_fixed_version
|
|
235 |
with_settings(:notified_events => [], :notified_event_issue_attr_updated_details => []) do
|
| 187 |
236 |
user = User.find_by_login('jsmith')
|
| 188 |
237 |
issue = issues(:issues_001)
|
| 189 |
238 |
issue.init_journal(user)
|
| ... | ... | |
| 223 |
272 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
| 224 |
273 |
end
|
| 225 |
274 |
end
|
|
275 |
|
|
276 |
def test_notify_on_issue_relation_updated_with_selected_relation_type
|
|
277 |
issue = Issue.first
|
|
278 |
other_issue = Issue.generate!(:assigned_to_id => 2)
|
|
279 |
user = User.first
|
|
280 |
issue.init_journal(user)
|
|
281 |
|
|
282 |
with_settings(notified_events: [], notified_event_issue_relation_updated_details: %w(relates)) do
|
|
283 |
IssueRelation.create!(
|
|
284 |
issue_from: issue,
|
|
285 |
issue_to: other_issue,
|
|
286 |
relation_type: 'relates'
|
|
287 |
)
|
|
288 |
end
|
|
289 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
290 |
end
|
|
291 |
|
|
292 |
def test_notify_on_issue_relation_updated_when_event_enabled
|
|
293 |
issue = Issue.first
|
|
294 |
other_issue = Issue.generate!(:assigned_to_id => 2)
|
|
295 |
user = User.first
|
|
296 |
issue.init_journal(user)
|
|
297 |
|
|
298 |
with_settings(:notified_events => %w(issue_relation_updated), :notified_event_issue_attr_updated_details => []) do
|
|
299 |
IssueRelation.create!(
|
|
300 |
issue_from: issue,
|
|
301 |
issue_to: other_issue,
|
|
302 |
relation_type: 'relates'
|
|
303 |
)
|
|
304 |
end
|
|
305 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
306 |
end
|
|
307 |
|
|
308 |
def test_do_not_notify_on_issue_relation_updated_with_unselected_relation_type
|
|
309 |
issue = Issue.first
|
|
310 |
other_issue = Issue.generate!(:assigned_to_id => 2)
|
|
311 |
user = User.first
|
|
312 |
issue.init_journal(user)
|
|
313 |
|
|
314 |
with_settings(notified_events: [], notified_event_issue_relation_updated_details: %w(blocks follows)) do
|
|
315 |
IssueRelation.create!(
|
|
316 |
issue_from: issue,
|
|
317 |
issue_to: other_issue,
|
|
318 |
relation_type: 'relates'
|
|
319 |
)
|
|
320 |
end
|
|
321 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
322 |
end
|
|
323 |
|
|
324 |
def test_notify_on_issue_relation_updated_with_selected_relation_type_follows
|
|
325 |
issue = Issue.first
|
|
326 |
other_issue = Issue.generate!(:assigned_to_id => 2)
|
|
327 |
user = User.first
|
|
328 |
issue.init_journal(user)
|
|
329 |
|
|
330 |
with_settings(notified_events: [], notified_event_issue_relation_updated_details: %w(blocks follows)) do
|
|
331 |
IssueRelation.create!(
|
|
332 |
issue_from: issue,
|
|
333 |
issue_to: other_issue,
|
|
334 |
relation_type: 'follows'
|
|
335 |
)
|
|
336 |
end
|
|
337 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
338 |
end
|
|
339 |
|
|
340 |
def test_notify_on_issue_custom_field_updated_with_selected_custom_field
|
|
341 |
issue = Issue.first
|
|
342 |
user = User.first
|
|
343 |
cf = IssueCustomField.find_by!(field_format: 'string')
|
|
344 |
issue.init_journal(user)
|
|
345 |
issue.custom_field_values = { cf.id => 'New value' }
|
|
346 |
|
|
347 |
with_settings(:notified_events => [], :notified_event_issue_cf_updated_details => [cf.id.to_s]) do
|
|
348 |
assert issue.save
|
|
349 |
end
|
|
350 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
351 |
end
|
|
352 |
|
|
353 |
def test_notify_on_issue_custom_field_updated_when_event_enabled
|
|
354 |
issue = Issue.first
|
|
355 |
user = User.first
|
|
356 |
cf = IssueCustomField.find_by!(field_format: 'string')
|
|
357 |
issue.init_journal(user)
|
|
358 |
issue.custom_field_values = { cf.id => 'Changed value' }
|
|
359 |
|
|
360 |
with_settings(notified_events: %w(issue_cf_updated), notified_event_issue_cf_updated_details: []) do
|
|
361 |
assert issue.save
|
|
362 |
end
|
|
363 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
364 |
end
|
|
365 |
|
|
366 |
def test_do_not_notify_on_issue_custom_field_updated_with_unselected_custom_field
|
|
367 |
issue = Issue.first
|
|
368 |
user = User.first
|
|
369 |
cf1 = IssueCustomField.find_by!(field_format: 'string')
|
|
370 |
cf2 = IssueCustomField.create!(
|
|
371 |
name: 'Second CF',
|
|
372 |
field_format: 'string',
|
|
373 |
is_for_all: true,
|
|
374 |
trackers: Tracker.all
|
|
375 |
)
|
|
376 |
issue.init_journal(user)
|
|
377 |
issue.custom_field_values = { cf2.id => 'Ignored value' }
|
|
378 |
|
|
379 |
with_settings(notified_events: [], notified_event_issue_cf_updated_details: [cf1.id.to_s]) do
|
|
380 |
assert issue.save
|
|
381 |
end
|
|
382 |
assert_equal 0, ActionMailer::Base.deliveries.size
|
|
383 |
end
|
|
384 |
|
|
385 |
def test_notify_on_issue_custom_field_updated_with_other_selected_custom_field
|
|
386 |
issue = Issue.first
|
|
387 |
user = User.first
|
|
388 |
cf1 = IssueCustomField.find_by!(field_format: 'string')
|
|
389 |
cf2 = IssueCustomField.create!(
|
|
390 |
name: 'Second CF',
|
|
391 |
field_format: 'string',
|
|
392 |
is_for_all: true,
|
|
393 |
trackers: Tracker.all
|
|
394 |
)
|
|
395 |
issue.init_journal(user)
|
|
396 |
issue.custom_field_values = { cf2.id => 'Relevant value' }
|
|
397 |
|
|
398 |
with_settings(notified_events: [], notified_event_issue_cf_updated_details: [cf2.id.to_s]) do
|
|
399 |
assert issue.save
|
|
400 |
end
|
|
401 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
402 |
end
|
|
403 |
|
|
404 |
def test_notify_on_issue_custom_field_updated_with_multiple_selected_custom_fields
|
|
405 |
issue = Issue.first
|
|
406 |
user = User.first
|
|
407 |
cf1 = IssueCustomField.find_by!(field_format: 'string')
|
|
408 |
cf2 = IssueCustomField.create!(
|
|
409 |
name: 'Second CF',
|
|
410 |
field_format: 'string',
|
|
411 |
is_for_all: true,
|
|
412 |
trackers: Tracker.all
|
|
413 |
)
|
|
414 |
issue.init_journal(user)
|
|
415 |
issue.custom_field_values = { cf2.id => 'Matching value' }
|
|
416 |
|
|
417 |
with_settings(notified_events: [], notified_event_issue_cf_updated_details: [cf1.id.to_s, cf2.id.to_s]) do
|
|
418 |
assert issue.save
|
|
419 |
end
|
|
420 |
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
421 |
end
|
| 226 |
422 |
end
|