aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/lib/action_mailer/async.rb10
-rw-r--r--actionmailer/test/base_test.rb8
2 files changed, 16 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/async.rb b/actionmailer/lib/action_mailer/async.rb
index cbadd3dc25..fd62c57790 100644
--- a/actionmailer/lib/action_mailer/async.rb
+++ b/actionmailer/lib/action_mailer/async.rb
@@ -27,8 +27,14 @@ module ActionMailer::Async
end
# Will push the message onto the Queue to be processed
- def deliver
- Rails.queue << self
+ # To force message delivery dispite async pass `true`
+ # Emailer.welcome.deliver(true)
+ def deliver(force = false)
+ if force
+ run
+ else
+ Rails.queue << self
+ end
end
# The original ActionMailer message
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index fdc784029b..908ce719b5 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -432,6 +432,14 @@ class BaseTest < ActiveSupport::TestCase
assert_equal(1, AsyncMailer.deliveries.length)
end
+ test "forcing message delivery despite asynchronous" do
+ Rails.stubs(:queue).returns(Rails::Queueing::TestQueue.new)
+ AsyncMailer.delivery_method = :test
+ AsyncMailer.deliveries.clear
+ AsyncMailer.welcome.deliver(true)
+ assert_equal(1, AsyncMailer.deliveries.length)
+ end
+
test "calling deliver, ActionMailer should yield back to mail to let it call :do_delivery on itself" do
mail = Mail::Message.new
mail.expects(:do_delivery).once