mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Deprecated .deliver / .deliver! to .deliver_now / .deliver_now!
This commit is contained in:
parent
500deece9e
commit
f4ee114746
9 changed files with 92 additions and 53 deletions
|
@ -21,11 +21,31 @@ module ActionMailer
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_later!(options={})
|
def deliver_later!(options={})
|
||||||
enqueue_delivery :deliver!, options
|
enqueue_delivery :deliver_now!, options
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_later(options={})
|
def deliver_later(options={})
|
||||||
enqueue_delivery :deliver, options
|
enqueue_delivery :deliver_now, options
|
||||||
|
end
|
||||||
|
|
||||||
|
def deliver_now!
|
||||||
|
message.deliver!
|
||||||
|
end
|
||||||
|
|
||||||
|
def deliver_now
|
||||||
|
message.deliver
|
||||||
|
end
|
||||||
|
|
||||||
|
def deliver!
|
||||||
|
ActiveSupport::Deprecation.warn "#deliver! is deprecated and will be removed on Rails 5. " \
|
||||||
|
"Use #deliver_now! to deliver immediately or #deliver_later! to deliver through ActiveJob"
|
||||||
|
deliver_now!
|
||||||
|
end
|
||||||
|
|
||||||
|
def deliver
|
||||||
|
ActiveSupport::Deprecation.warn "#deliver is deprecated and will be removed on Rails 5. " \
|
||||||
|
"Use #deliver_now to deliver immediately or #deliver_later to deliver through ActiveJob"
|
||||||
|
deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AssertSelectEmailTest < ActionMailer::TestCase
|
||||||
assert_select_email {}
|
assert_select_email {}
|
||||||
end
|
end
|
||||||
|
|
||||||
AssertSelectMailer.test("<div><p>foo</p><p>bar</p></div>").deliver
|
AssertSelectMailer.test("<div><p>foo</p><p>bar</p></div>").deliver_now
|
||||||
assert_select_email do
|
assert_select_email do
|
||||||
assert_select "div:root" do
|
assert_select "div:root" do
|
||||||
assert_select "p:first-child", "foo"
|
assert_select "p:first-child", "foo"
|
||||||
|
@ -36,7 +36,7 @@ class AssertSelectEmailTest < ActionMailer::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assert_select_email_multipart
|
def test_assert_select_email_multipart
|
||||||
AssertMultipartSelectMailer.test(html: "<div><p>foo</p><p>bar</p></div>", text: 'foo bar').deliver
|
AssertMultipartSelectMailer.test(html: "<div><p>foo</p><p>bar</p></div>", text: 'foo bar').deliver_now
|
||||||
assert_select_email do
|
assert_select_email do
|
||||||
assert_select "div:root" do
|
assert_select "div:root" do
|
||||||
assert_select "p:first-child", "foo"
|
assert_select "p:first-child", "foo"
|
||||||
|
|
|
@ -466,12 +466,12 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test "calling deliver on the action should deliver the mail object" do
|
test "calling deliver on the action should deliver the mail object" do
|
||||||
BaseMailer.expects(:deliver_mail).once
|
BaseMailer.expects(:deliver_mail).once
|
||||||
mail = BaseMailer.welcome.deliver
|
mail = BaseMailer.welcome.deliver_now
|
||||||
assert_equal 'The first email on new API!', mail.subject
|
assert_equal 'The first email on new API!', mail.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
test "calling deliver on the action should increment the deliveries collection if using the test mailer" do
|
test "calling deliver on the action should increment the deliveries collection if using the test mailer" do
|
||||||
BaseMailer.welcome.deliver
|
BaseMailer.welcome.deliver_now
|
||||||
assert_equal(1, BaseMailer.deliveries.length)
|
assert_equal(1, BaseMailer.deliveries.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -484,35 +484,35 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# Rendering
|
# Rendering
|
||||||
test "you can specify a different template for implicit render" do
|
test "you can specify a different template for implicit render" do
|
||||||
mail = BaseMailer.implicit_different_template('implicit_multipart').deliver
|
mail = BaseMailer.implicit_different_template('implicit_multipart').deliver_now
|
||||||
assert_equal("HTML Implicit Multipart", mail.html_part.body.decoded)
|
assert_equal("HTML Implicit Multipart", mail.html_part.body.decoded)
|
||||||
assert_equal("TEXT Implicit Multipart", mail.text_part.body.decoded)
|
assert_equal("TEXT Implicit Multipart", mail.text_part.body.decoded)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should raise if missing template in implicit render" do
|
test "should raise if missing template in implicit render" do
|
||||||
assert_raises ActionView::MissingTemplate do
|
assert_raises ActionView::MissingTemplate do
|
||||||
BaseMailer.implicit_different_template('missing_template').deliver
|
BaseMailer.implicit_different_template('missing_template').deliver_now
|
||||||
end
|
end
|
||||||
assert_equal(0, BaseMailer.deliveries.length)
|
assert_equal(0, BaseMailer.deliveries.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "you can specify a different template for explicit render" do
|
test "you can specify a different template for explicit render" do
|
||||||
mail = BaseMailer.explicit_different_template('explicit_multipart_templates').deliver
|
mail = BaseMailer.explicit_different_template('explicit_multipart_templates').deliver_now
|
||||||
assert_equal("HTML Explicit Multipart Templates", mail.html_part.body.decoded)
|
assert_equal("HTML Explicit Multipart Templates", mail.html_part.body.decoded)
|
||||||
assert_equal("TEXT Explicit Multipart Templates", mail.text_part.body.decoded)
|
assert_equal("TEXT Explicit Multipart Templates", mail.text_part.body.decoded)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "you can specify a different layout" do
|
test "you can specify a different layout" do
|
||||||
mail = BaseMailer.different_layout('different_layout').deliver
|
mail = BaseMailer.different_layout('different_layout').deliver_now
|
||||||
assert_equal("HTML -- HTML", mail.html_part.body.decoded)
|
assert_equal("HTML -- HTML", mail.html_part.body.decoded)
|
||||||
assert_equal("PLAIN -- PLAIN", mail.text_part.body.decoded)
|
assert_equal("PLAIN -- PLAIN", mail.text_part.body.decoded)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "you can specify the template path for implicit lookup" do
|
test "you can specify the template path for implicit lookup" do
|
||||||
mail = BaseMailer.welcome_from_another_path('another.path/base_mailer').deliver
|
mail = BaseMailer.welcome_from_another_path('another.path/base_mailer').deliver_now
|
||||||
assert_equal("Welcome from another path", mail.body.encoded)
|
assert_equal("Welcome from another path", mail.body.encoded)
|
||||||
|
|
||||||
mail = BaseMailer.welcome_from_another_path(['unknown/invalid', 'another.path/base_mailer']).deliver
|
mail = BaseMailer.welcome_from_another_path(['unknown/invalid', 'another.path/base_mailer']).deliver_now
|
||||||
assert_equal("Welcome from another path", mail.body.encoded)
|
assert_equal("Welcome from another path", mail.body.encoded)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -542,13 +542,13 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
test 'the view is not rendered when mail was never called' do
|
test 'the view is not rendered when mail was never called' do
|
||||||
mail = BaseMailer.without_mail_call
|
mail = BaseMailer.without_mail_call
|
||||||
assert_equal('', mail.body.to_s.strip)
|
assert_equal('', mail.body.to_s.strip)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'the return value of mailer methods is not relevant' do
|
test 'the return value of mailer methods is not relevant' do
|
||||||
mail = BaseMailer.with_nil_as_return_value
|
mail = BaseMailer.with_nil_as_return_value
|
||||||
assert_equal('Welcome', mail.body.to_s.strip)
|
assert_equal('Welcome', mail.body.to_s.strip)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
# Before and After hooks
|
# Before and After hooks
|
||||||
|
@ -568,7 +568,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_observer(MyObserver)
|
ActionMailer::Base.register_observer(MyObserver)
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyObserver.expects(:delivered_email).with(mail)
|
MyObserver.expects(:delivered_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_observer("BaseTest::MyObserver")
|
ActionMailer::Base.register_observer("BaseTest::MyObserver")
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyObserver.expects(:delivered_email).with(mail)
|
MyObserver.expects(:delivered_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_observer(:"base_test/my_observer")
|
ActionMailer::Base.register_observer(:"base_test/my_observer")
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyObserver.expects(:delivered_email).with(mail)
|
MyObserver.expects(:delivered_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyObserver.expects(:delivered_email).with(mail)
|
MyObserver.expects(:delivered_email).with(mail)
|
||||||
MySecondObserver.expects(:delivered_email).with(mail)
|
MySecondObserver.expects(:delivered_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_interceptor(MyInterceptor)
|
ActionMailer::Base.register_interceptor(MyInterceptor)
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyInterceptor.expects(:delivering_email).with(mail)
|
MyInterceptor.expects(:delivering_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_interceptor("BaseTest::MyInterceptor")
|
ActionMailer::Base.register_interceptor("BaseTest::MyInterceptor")
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyInterceptor.expects(:delivering_email).with(mail)
|
MyInterceptor.expects(:delivering_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
ActionMailer::Base.register_interceptor(:"base_test/my_interceptor")
|
ActionMailer::Base.register_interceptor(:"base_test/my_interceptor")
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyInterceptor.expects(:delivering_email).with(mail)
|
MyInterceptor.expects(:delivering_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ class BaseTest < ActiveSupport::TestCase
|
||||||
mail = BaseMailer.welcome
|
mail = BaseMailer.welcome
|
||||||
MyInterceptor.expects(:delivering_email).with(mail)
|
MyInterceptor.expects(:delivering_email).with(mail)
|
||||||
MySecondInterceptor.expects(:delivering_email).with(mail)
|
MySecondInterceptor.expects(:delivering_email).with(mail)
|
||||||
mail.deliver
|
mail.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -104,21 +104,21 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test "ActionMailer should be told when Mail gets delivered" do
|
test "ActionMailer should be told when Mail gets delivered" do
|
||||||
DeliveryMailer.expects(:deliver_mail).once
|
DeliveryMailer.expects(:deliver_mail).once
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delivery method can be customized per instance" do
|
test "delivery method can be customized per instance" do
|
||||||
Mail::SMTP.any_instance.expects(:deliver!)
|
Mail::SMTP.any_instance.expects(:deliver!)
|
||||||
email = DeliveryMailer.welcome.deliver
|
email = DeliveryMailer.welcome.deliver_now
|
||||||
assert_instance_of Mail::SMTP, email.delivery_method
|
assert_instance_of Mail::SMTP, email.delivery_method
|
||||||
email = DeliveryMailer.welcome(delivery_method: :test).deliver
|
email = DeliveryMailer.welcome(delivery_method: :test).deliver_now
|
||||||
assert_instance_of Mail::TestMailer, email.delivery_method
|
assert_instance_of Mail::TestMailer, email.delivery_method
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delivery method can be customized in subclasses not changing the parent" do
|
test "delivery method can be customized in subclasses not changing the parent" do
|
||||||
DeliveryMailer.delivery_method = :test
|
DeliveryMailer.delivery_method = :test
|
||||||
assert_equal :smtp, ActionMailer::Base.delivery_method
|
assert_equal :smtp, ActionMailer::Base.delivery_method
|
||||||
email = DeliveryMailer.welcome.deliver
|
email = DeliveryMailer.welcome.deliver_now
|
||||||
assert_instance_of Mail::TestMailer, email.delivery_method
|
assert_instance_of Mail::TestMailer, email.delivery_method
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -162,14 +162,14 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
test "non registered delivery methods raises errors" do
|
test "non registered delivery methods raises errors" do
|
||||||
DeliveryMailer.delivery_method = :unknown
|
DeliveryMailer.delivery_method = :unknown
|
||||||
assert_raise RuntimeError do
|
assert_raise RuntimeError do
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "undefined delivery methods raises errors" do
|
test "undefined delivery methods raises errors" do
|
||||||
DeliveryMailer.delivery_method = nil
|
DeliveryMailer.delivery_method = nil
|
||||||
assert_raise RuntimeError do
|
assert_raise RuntimeError do
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
begin
|
begin
|
||||||
DeliveryMailer.perform_deliveries = false
|
DeliveryMailer.perform_deliveries = false
|
||||||
Mail::Message.any_instance.expects(:deliver!).never
|
Mail::Message.any_instance.expects(:deliver!).never
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
ensure
|
ensure
|
||||||
DeliveryMailer.perform_deliveries = old_perform_deliveries
|
DeliveryMailer.perform_deliveries = old_perform_deliveries
|
||||||
end
|
end
|
||||||
|
@ -188,7 +188,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
old_perform_deliveries = DeliveryMailer.perform_deliveries
|
old_perform_deliveries = DeliveryMailer.perform_deliveries
|
||||||
begin
|
begin
|
||||||
DeliveryMailer.perform_deliveries = false
|
DeliveryMailer.perform_deliveries = false
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
assert_equal [], DeliveryMailer.deliveries
|
assert_equal [], DeliveryMailer.deliveries
|
||||||
ensure
|
ensure
|
||||||
DeliveryMailer.perform_deliveries = old_perform_deliveries
|
DeliveryMailer.perform_deliveries = old_perform_deliveries
|
||||||
|
@ -198,14 +198,14 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
test "raise errors on bogus deliveries" do
|
test "raise errors on bogus deliveries" do
|
||||||
DeliveryMailer.delivery_method = BogusDelivery
|
DeliveryMailer.delivery_method = BogusDelivery
|
||||||
assert_raise RuntimeError do
|
assert_raise RuntimeError do
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not increment the deliveries collection on error" do
|
test "does not increment the deliveries collection on error" do
|
||||||
DeliveryMailer.delivery_method = BogusDelivery
|
DeliveryMailer.delivery_method = BogusDelivery
|
||||||
assert_raise RuntimeError do
|
assert_raise RuntimeError do
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
assert_equal [], DeliveryMailer.deliveries
|
assert_equal [], DeliveryMailer.deliveries
|
||||||
end
|
end
|
||||||
|
@ -216,7 +216,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
DeliveryMailer.delivery_method = BogusDelivery
|
DeliveryMailer.delivery_method = BogusDelivery
|
||||||
DeliveryMailer.raise_delivery_errors = false
|
DeliveryMailer.raise_delivery_errors = false
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
DeliveryMailer.raise_delivery_errors = old_raise_delivery_errors
|
DeliveryMailer.raise_delivery_errors = old_raise_delivery_errors
|
||||||
|
@ -228,7 +228,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
|
||||||
begin
|
begin
|
||||||
DeliveryMailer.delivery_method = BogusDelivery
|
DeliveryMailer.delivery_method = BogusDelivery
|
||||||
DeliveryMailer.raise_delivery_errors = false
|
DeliveryMailer.raise_delivery_errors = false
|
||||||
DeliveryMailer.welcome.deliver
|
DeliveryMailer.welcome.deliver_now
|
||||||
assert_equal [], DeliveryMailer.deliveries
|
assert_equal [], DeliveryMailer.deliveries
|
||||||
ensure
|
ensure
|
||||||
DeliveryMailer.raise_delivery_errors = old_raise_delivery_errors
|
DeliveryMailer.raise_delivery_errors = old_raise_delivery_errors
|
||||||
|
|
|
@ -17,7 +17,7 @@ end
|
||||||
|
|
||||||
class TestController < ActionController::Base
|
class TestController < ActionController::Base
|
||||||
def send_mail
|
def send_mail
|
||||||
email = I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver
|
email = I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver_now
|
||||||
render text: "Mail sent - Subject: #{email.subject}"
|
render text: "Mail sent - Subject: #{email.subject}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ class AMLogSubscriberTest < ActionMailer::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deliver_is_notified
|
def test_deliver_is_notified
|
||||||
BaseMailer.welcome.deliver
|
BaseMailer.welcome.deliver_now
|
||||||
wait
|
wait
|
||||||
|
|
||||||
assert_equal(1, @logger.logged(:info).size)
|
assert_equal(1, @logger.logged(:info).size)
|
||||||
|
|
|
@ -37,6 +37,17 @@ class MessageDeliveryTest < ActiveSupport::TestCase
|
||||||
assert_respond_to @mail, :deliver!
|
assert_respond_to @mail, :deliver!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test '.deliver is deprecated' do
|
||||||
|
assert_deprecated do
|
||||||
|
@mail.deliver
|
||||||
|
end
|
||||||
|
end
|
||||||
|
test '.deliver! is deprecated' do
|
||||||
|
assert_deprecated do
|
||||||
|
@mail.deliver!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test 'should respond to .deliver_later' do
|
test 'should respond to .deliver_later' do
|
||||||
assert_respond_to @mail, :deliver_later
|
assert_respond_to @mail, :deliver_later
|
||||||
end
|
end
|
||||||
|
@ -45,7 +56,15 @@ class MessageDeliveryTest < ActiveSupport::TestCase
|
||||||
assert_respond_to @mail, :deliver_later!
|
assert_respond_to @mail, :deliver_later!
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_enqueue_and_run_correctly_in_activejob
|
test 'should respond to .deliver_now' do
|
||||||
|
assert_respond_to @mail, :deliver_now
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should respond to .deliver_now!' do
|
||||||
|
assert_respond_to @mail, :deliver_now!
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'should enqueue and run correctly in activejob' do
|
||||||
@mail.deliver_later!
|
@mail.deliver_later!
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
ensure
|
ensure
|
||||||
|
@ -56,21 +75,21 @@ class MessageDeliveryTest < ActiveSupport::TestCase
|
||||||
ret = ActionMailer::DeliveryJob.stub :enqueue, ->(*args){ args } do
|
ret = ActionMailer::DeliveryJob.stub :enqueue, ->(*args){ args } do
|
||||||
@mail.deliver_later
|
@mail.deliver_later
|
||||||
end
|
end
|
||||||
assert_equal ['DelayedMailer', 'test_message', 'deliver', 1, 2, 3], ret
|
assert_equal ['DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3], ret
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should enqueue the email with :deliver! delivery method' do
|
test 'should enqueue the email with :deliver! delivery method' do
|
||||||
ret = ActionMailer::DeliveryJob.stub :enqueue, ->(*args){ args } do
|
ret = ActionMailer::DeliveryJob.stub :enqueue, ->(*args){ args } do
|
||||||
@mail.deliver_later!
|
@mail.deliver_later!
|
||||||
end
|
end
|
||||||
assert_equal ['DelayedMailer', 'test_message', 'deliver!', 1, 2, 3], ret
|
assert_equal ['DelayedMailer', 'test_message', 'deliver_now!', 1, 2, 3], ret
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should enqueue a delivery with a delay' do
|
test 'should enqueue a delivery with a delay' do
|
||||||
ret = ActionMailer::DeliveryJob.stub :enqueue_in, ->(*args){ args } do
|
ret = ActionMailer::DeliveryJob.stub :enqueue_in, ->(*args){ args } do
|
||||||
@mail.deliver_later in: 600
|
@mail.deliver_later in: 600
|
||||||
end
|
end
|
||||||
assert_equal [600, 'DelayedMailer', 'test_message', 'deliver', 1, 2, 3], ret
|
assert_equal [600, 'DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3], ret
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should enqueue a delivery at a specific time' do
|
test 'should enqueue a delivery at a specific time' do
|
||||||
|
@ -78,7 +97,7 @@ class MessageDeliveryTest < ActiveSupport::TestCase
|
||||||
ret = ActionMailer::DeliveryJob.stub :enqueue_at, ->(*args){ args } do
|
ret = ActionMailer::DeliveryJob.stub :enqueue_at, ->(*args){ args } do
|
||||||
@mail.deliver_later at: later_time
|
@mail.deliver_later at: later_time
|
||||||
end
|
end
|
||||||
assert_equal [later_time, 'DelayedMailer', 'test_message', 'deliver', 1, 2, 3], ret
|
assert_equal [later_time, 'DelayedMailer', 'test_message', 'deliver_now', 1, 2, 3], ret
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
|
||||||
def test_assert_emails
|
def test_assert_emails
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,27 +56,27 @@ class TestHelperMailerTest < ActionMailer::TestCase
|
||||||
def test_repeated_assert_emails_calls
|
def test_repeated_assert_emails_calls
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
assert_emails 2 do
|
assert_emails 2 do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assert_emails_with_no_block
|
def test_assert_emails_with_no_block
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
assert_emails 1
|
assert_emails 1
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
assert_emails 3
|
assert_emails 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
|
||||||
def test_assert_emails_too_few_sent
|
def test_assert_emails_too_few_sent
|
||||||
error = assert_raise ActiveSupport::TestCase::Assertion do
|
error = assert_raise ActiveSupport::TestCase::Assertion do
|
||||||
assert_emails 2 do
|
assert_emails 2 do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ class TestHelperMailerTest < ActionMailer::TestCase
|
||||||
def test_assert_emails_too_many_sent
|
def test_assert_emails_too_many_sent
|
||||||
error = assert_raise ActiveSupport::TestCase::Assertion do
|
error = assert_raise ActiveSupport::TestCase::Assertion do
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
|
||||||
def test_assert_no_emails_failure
|
def test_assert_no_emails_failure
|
||||||
error = assert_raise ActiveSupport::TestCase::Assertion do
|
error = assert_raise ActiveSupport::TestCase::Assertion do
|
||||||
assert_no_emails do
|
assert_no_emails do
|
||||||
TestHelperMailer.test.deliver
|
TestHelperMailer.test.deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase
|
||||||
created.message_id = '<123@456>'
|
created.message_id = '<123@456>'
|
||||||
assert_equal expected.encoded, created.encoded
|
assert_equal expected.encoded, created.encoded
|
||||||
|
|
||||||
assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver }
|
assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver_now }
|
||||||
assert_not_nil ActionMailer::Base.deliveries.first
|
assert_not_nil ActionMailer::Base.deliveries.first
|
||||||
delivered = ActionMailer::Base.deliveries.first
|
delivered = ActionMailer::Base.deliveries.first
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue