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