blob: dd338ea47c78a44ced1da79b225fcd1d23c56fef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
# Note that we actually update the attribute on the target_project/group, rather than
# using `allow`. This is because there are some specs where, based on how the notification
# is done, using an `allow` doesn't change the correct object.
shared_examples 'project emails are disabled' do
let(:target_project) { notification_target.is_a?(Project) ? notification_target : notification_target.project }
before do
reset_delivered_emails!
target_project.clear_memoization(:emails_disabled)
end
it 'sends no emails with project emails disabled' do
target_project.update_attribute(:emails_disabled, true)
notification_trigger
should_not_email_anyone
end
it 'sends emails to someone' do
target_project.update_attribute(:emails_disabled, false)
notification_trigger
should_email_anyone
end
end
shared_examples 'group emails are disabled' do
let(:target_group) { notification_target.is_a?(Group) ? notification_target : notification_target.project.group }
before do
reset_delivered_emails!
target_group.clear_memoization(:emails_disabled)
end
it 'sends no emails with group emails disabled' do
target_group.update_attribute(:emails_disabled, true)
notification_trigger
should_not_email_anyone
end
it 'sends emails to someone' do
target_group.update_attribute(:emails_disabled, false)
notification_trigger
should_email_anyone
end
end
|