Commit ef2c8593b9f80951e97fadb5a3c9c5cdf0f1b1c9
1 parent
e996c526
Exists in
master
and in
4 other branches
Disable mailer for spinach
Showing
2 changed files
with
18 additions
and
10 deletions
Show diff stats
app/services/notification_service.rb
... | ... | @@ -13,7 +13,7 @@ class NotificationService |
13 | 13 | # even if user disabled notifications |
14 | 14 | def new_key(key) |
15 | 15 | if key.user |
16 | - Notify.delay.new_ssh_key_email(key.id) | |
16 | + mailer.new_ssh_key_email(key.id) | |
17 | 17 | end |
18 | 18 | end |
19 | 19 | |
... | ... | @@ -84,14 +84,14 @@ class NotificationService |
84 | 84 | recipients = recipients.concat(project_watchers(merge_request.project)).uniq |
85 | 85 | |
86 | 86 | recipients.each do |recipient| |
87 | - Notify.delay.merged_merge_request_email(recipient.id, merge_request.id) | |
87 | + mailer.merged_merge_request_email(recipient.id, merge_request.id) | |
88 | 88 | end |
89 | 89 | end |
90 | 90 | |
91 | 91 | # Notify new user with email after creation |
92 | 92 | def new_user(user) |
93 | 93 | # Dont email omniauth created users |
94 | - Notify.delay.new_user_email(user.id, user.password) unless user.extern_uid? | |
94 | + mailer.new_user_email(user.id, user.password) unless user.extern_uid? | |
95 | 95 | end |
96 | 96 | |
97 | 97 | # Notify users on new note in system |
... | ... | @@ -131,16 +131,16 @@ class NotificationService |
131 | 131 | notify_method = "note_#{note.noteable_type.underscore}_email".to_sym |
132 | 132 | |
133 | 133 | recipients.each do |recipient| |
134 | - Notify.delay.send(notify_method, recipient.id, note.id) | |
134 | + mailer.send(notify_method, recipient.id, note.id) | |
135 | 135 | end |
136 | 136 | end |
137 | 137 | |
138 | 138 | def new_team_member(users_project) |
139 | - Notify.delay.project_access_granted_email(users_project.id) | |
139 | + mailer.project_access_granted_email(users_project.id) | |
140 | 140 | end |
141 | 141 | |
142 | 142 | def update_team_member(users_project) |
143 | - Notify.delay.project_access_granted_email(users_project.id) | |
143 | + mailer.project_access_granted_email(users_project.id) | |
144 | 144 | end |
145 | 145 | |
146 | 146 | protected |
... | ... | @@ -186,7 +186,7 @@ class NotificationService |
186 | 186 | recipients.delete(target.author) |
187 | 187 | |
188 | 188 | recipients.each do |recipient| |
189 | - Notify.delay.send(method, recipient.id, target.id) | |
189 | + mailer.send(method, recipient.id, target.id) | |
190 | 190 | end |
191 | 191 | end |
192 | 192 | |
... | ... | @@ -196,7 +196,7 @@ class NotificationService |
196 | 196 | recipients.delete(current_user) |
197 | 197 | |
198 | 198 | recipients.each do |recipient| |
199 | - Notify.delay.send(method, recipient.id, target.id, current_user.id) | |
199 | + mailer.send(method, recipient.id, target.id, current_user.id) | |
200 | 200 | end |
201 | 201 | end |
202 | 202 | |
... | ... | @@ -213,7 +213,11 @@ class NotificationService |
213 | 213 | recipients.delete(current_user) |
214 | 214 | |
215 | 215 | recipients.each do |recipient| |
216 | - Notify.delay.send(method, recipient.id, target.id, target.assignee_id_was) | |
216 | + mailer.send(method, recipient.id, target.id, target.assignee_id_was) | |
217 | 217 | end |
218 | 218 | end |
219 | + | |
220 | + def mailer | |
221 | + Notify.delay | |
222 | + end | |
219 | 223 | end | ... | ... |
spec/support/test_env.rb
1 | +require 'rspec/mocks' | |
2 | + | |
1 | 3 | module TestEnv |
2 | 4 | extend self |
3 | 5 | |
... | ... | @@ -13,6 +15,8 @@ module TestEnv |
13 | 15 | # - remove_key |
14 | 16 | # |
15 | 17 | def init(opts = {}) |
18 | + RSpec::Mocks::setup(self) | |
19 | + | |
16 | 20 | # Disable observers to improve test speed |
17 | 21 | # |
18 | 22 | # You can enable it in whole test case where needed by next string: |
... | ... | @@ -82,6 +86,6 @@ module TestEnv |
82 | 86 | end |
83 | 87 | |
84 | 88 | def disable_mailer |
85 | - ActionMailer::Base.perform_deliveries = false | |
89 | + NotificationService.any_instance.stub(mailer: double.as_null_object) | |
86 | 90 | end |
87 | 91 | end | ... | ... |