44
44
end
45
45
46
46
it do
47
-
48
- mail . execute ( build )
49
- end
50
-
51
- def should_email ( email )
52
- expect ( Ci ::Notify ) . to receive ( :build_fail_email ) . with ( build . id , email )
53
- expect ( Ci ::Notify ) . not_to receive ( :build_success_email ) . with ( build . id , email )
47
+ perform_enqueued_jobs do
48
+ expect { mail . execute ( build ) } . to change { ActionMailer ::Base . deliveries . size } . by ( 1 )
49
+ expect ( ActionMailer ::
Base . deliveries . last . to ) . to eq ( [ "[email protected] " ] )
50
+ end
54
51
end
55
52
end
56
53
@@ -67,13 +64,10 @@ def should_email(email)
67
64
end
68
65
69
66
it do
70
-
71
- mail . execute ( build )
72
- end
73
-
74
- def should_email ( email )
75
- expect ( Ci ::Notify ) . to receive ( :build_success_email ) . with ( build . id , email )
76
- expect ( Ci ::Notify ) . not_to receive ( :build_fail_email ) . with ( build . id , email )
67
+ perform_enqueued_jobs do
68
+ expect { mail . execute ( build ) } . to change { ActionMailer ::Base . deliveries . size } . by ( 1 )
69
+ expect ( ActionMailer ::
Base . deliveries . last . to ) . to eq ( [ "[email protected] " ] )
70
+ end
77
71
end
78
72
end
79
73
@@ -95,14 +89,12 @@ def should_email(email)
95
89
end
96
90
97
91
it do
98
-
99
-
100
- mail . execute ( build )
101
- end
102
-
103
- def should_email ( email )
104
- expect ( Ci ::Notify ) . to receive ( :build_success_email ) . with ( build . id , email )
105
- expect ( Ci ::Notify ) . not_to receive ( :build_fail_email ) . with ( build . id , email )
92
+ perform_enqueued_jobs do
93
+ expect { mail . execute ( build ) } . to change { ActionMailer ::Base . deliveries . size } . by ( 2 )
94
+ expect (
95
+ ActionMailer ::Base . deliveries . map ( &:to ) . flatten
96
+
97
+ end
106
98
end
107
99
end
108
100
@@ -124,14 +116,11 @@ def should_email(email)
124
116
end
125
117
126
118
it do
127
- should_email ( commit . git_author_email )
128
-
129
- mail . execute ( build ) if mail . can_execute? ( build )
130
- end
131
-
132
- def should_email ( email )
133
- expect ( Ci ::Notify ) . not_to receive ( :build_success_email ) . with ( build . id , email )
134
- expect ( Ci ::Notify ) . not_to receive ( :build_fail_email ) . with ( build . id , email )
119
+ perform_enqueued_jobs do
120
+ expect do
121
+ mail . execute ( build ) if mail . can_execute? ( build )
122
+ end . to_not change { ActionMailer ::Base . deliveries . size }
123
+ end
135
124
end
136
125
end
137
126
@@ -177,14 +166,11 @@ def should_email(email)
177
166
178
167
it do
179
168
Ci ::Build . retry ( build )
180
- should_email ( commit . git_author_email )
181
-
182
- mail . execute ( build ) if mail . can_execute? ( build )
183
- end
184
-
185
- def should_email ( email )
186
- expect ( Ci ::Notify ) . not_to receive ( :build_success_email ) . with ( build . id , email )
187
- expect ( Ci ::Notify ) . not_to receive ( :build_fail_email ) . with ( build . id , email )
169
+ perform_enqueued_jobs do
170
+ expect do
171
+ mail . execute ( build ) if mail . can_execute? ( build )
172
+ end . to_not change { ActionMailer ::Base . deliveries . size }
173
+ end
188
174
end
189
175
end
190
176
end
0 commit comments