diff options
author | Brian Cardarella <bcardarella@gmail.com> | 2012-06-23 23:42:03 -0400 |
---|---|---|
committer | Brian Cardarella <bcardarella@gmail.com> | 2012-06-23 23:42:03 -0400 |
commit | 812d1e88c5218d4075878559476eaad65df1b761 (patch) | |
tree | d0c48e151eebb3727724cedbdefa271351d47b10 /actionmailer/test | |
parent | dee0b23af22516f52892fbf6af635fc7d1689a0e (diff) | |
download | rails-812d1e88c5218d4075878559476eaad65df1b761.tar.gz rails-812d1e88c5218d4075878559476eaad65df1b761.tar.bz2 rails-812d1e88c5218d4075878559476eaad65df1b761.zip |
Support for custom queues on the mailer
Credit goes to *Aaron Patterson* (tenderlove)
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 908ce719b5..f1988a8230 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -422,22 +422,33 @@ class BaseTest < ActiveSupport::TestCase assert_equal(1, BaseMailer.deliveries.length) end + def stub_queue klass, queue + Class.new(klass) { + extend Module.new { + define_method :queue do + queue + end + } + } + end + test "delivering message asynchronously" do - Rails.stubs(:queue).returns(Rails::Queueing::TestQueue.new) + testing_queue = Rails::Queueing::TestQueue.new AsyncMailer.delivery_method = :test AsyncMailer.deliveries.clear - AsyncMailer.welcome.deliver + stub_queue(AsyncMailer, testing_queue).welcome.deliver assert_equal(0, AsyncMailer.deliveries.length) - Rails.queue.drain + testing_queue.drain assert_equal(1, AsyncMailer.deliveries.length) end test "forcing message delivery despite asynchronous" do - Rails.stubs(:queue).returns(Rails::Queueing::TestQueue.new) + testing_queue = Rails::Queueing::TestQueue.new AsyncMailer.delivery_method = :test AsyncMailer.deliveries.clear - AsyncMailer.welcome.deliver(true) + stub_queue(AsyncMailer, testing_queue).welcome.deliver(true) assert_equal(1, AsyncMailer.deliveries.length) + assert_predicate testing_queue, :empty? end test "calling deliver, ActionMailer should yield back to mail to let it call :do_delivery on itself" do |