mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix tests on action_mailer
Include appropriate helpers and use `assert_dom_equal` where applicable
This commit is contained in:
parent
03d30ce71c
commit
e6b0b760cc
4 changed files with 9 additions and 7 deletions
|
@ -16,7 +16,7 @@ module ActionMailer
|
|||
|
||||
include ActiveSupport::Testing::ConstantLookup
|
||||
include TestHelper
|
||||
include Rails::Dom::Testing::Assertions::SelectorAssertions
|
||||
include Rails::Dom::Testing::Assertions
|
||||
|
||||
included do
|
||||
class_attribute :_mailer_class
|
||||
|
|
|
@ -22,7 +22,7 @@ class AssetHostTest < ActionMailer::TestCase
|
|||
|
||||
def test_asset_host_as_string
|
||||
mail = AssetHostMailer.email_with_asset
|
||||
assert_equal %Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}, mail.body.to_s.strip
|
||||
assert_dom_equal %Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}, mail.body.to_s.strip
|
||||
end
|
||||
|
||||
def test_asset_host_as_one_argument_proc
|
||||
|
@ -32,6 +32,6 @@ class AssetHostTest < ActionMailer::TestCase
|
|||
end
|
||||
}
|
||||
mail = AssetHostMailer.email_with_asset
|
||||
assert_equal %Q{<img alt="Somelogo" src="http://images.example.com/images/somelogo.png" />}, mail.body.to_s.strip
|
||||
assert_dom_equal %Q{<img alt="Somelogo" src="http://images.example.com/images/somelogo.png" />}, mail.body.to_s.strip
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,8 @@ require 'mailers/proc_mailer'
|
|||
require 'mailers/asset_mailer'
|
||||
|
||||
class BaseTest < ActiveSupport::TestCase
|
||||
include Rails::Dom::Testing::Assertions
|
||||
|
||||
setup do
|
||||
@original_delivery_method = ActionMailer::Base.delivery_method
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
|
@ -536,7 +538,7 @@ class BaseTest < ActiveSupport::TestCase
|
|||
|
||||
mail = AssetMailer.welcome
|
||||
|
||||
assert_equal(%{<img alt="Dummy" src="http://global.com/images/dummy.png" />}, mail.body.to_s.strip)
|
||||
assert_dom_equal(%{<img alt="Dummy" src="http://global.com/images/dummy.png" />}, mail.body.to_s.strip)
|
||||
end
|
||||
|
||||
test "assets tags should use a Mailer's asset_host settings when available" do
|
||||
|
@ -550,7 +552,7 @@ class BaseTest < ActiveSupport::TestCase
|
|||
|
||||
mail = TempAssetMailer.welcome
|
||||
|
||||
assert_equal(%{<img alt="Dummy" src="http://local.com/images/dummy.png" />}, mail.body.to_s.strip)
|
||||
assert_dom_equal(%{<img alt="Dummy" src="http://local.com/images/dummy.png" />}, mail.body.to_s.strip)
|
||||
end
|
||||
|
||||
test 'the view is not rendered when mail was never called' do
|
||||
|
|
|
@ -66,13 +66,13 @@ class ActionMailerUrlTest < ActionMailer::TestCase
|
|||
|
||||
expected.message_id = '<123@456>'
|
||||
created.message_id = '<123@456>'
|
||||
assert_equal expected.encoded, created.encoded
|
||||
assert_dom_equal expected.encoded, created.encoded
|
||||
|
||||
assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver_now }
|
||||
assert_not_nil ActionMailer::Base.deliveries.first
|
||||
delivered = ActionMailer::Base.deliveries.first
|
||||
|
||||
delivered.message_id = '<123@456>'
|
||||
assert_equal expected.encoded, delivered.encoded
|
||||
assert_dom_equal expected.encoded, delivered.encoded
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue