summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/mailer.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 173e33c40..f39c53209 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -324,6 +324,15 @@ class Mailer < ActionMailer::Base
deliver_reminder(assignee, issues, days) unless assignee.nil?
end
end
+
+ # Activates/desactivates email deliveries during +block+
+ def self.with_deliveries(enabled = true, &block)
+ was_enabled = ActionMailer::Base.perform_deliveries
+ ActionMailer::Base.perform_deliveries = !!enabled
+ yield
+ ensure
+ ActionMailer::Base.perform_deliveries = was_enabled
+ end
private
def initialize_defaults(method_name)