1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actiontext/test/integration/mailer_render_test.rb
Jonathan Hefner 614e813161
Disentangle Action Text from ApplicationController
This commit allows Action Text to be used without having an
ApplicationController defined.  In doing so, it also fixes Action Text
attachments to render the correct URL host in mailers.

It also avoids allocating an ActionController::Renderer per request.

Fixes #37183.
Fixes #35578.
Fixes #36963.
Closes #38714.

Co-authored-by: Jeremy Daer <jeremydaer@gmail.com>
2020-10-30 01:01:42 +00:00

23 lines
799 B
Ruby

# frozen_string_literal: true
require "test_helper"
class ActionText::MailerRenderTest < ActionMailer::TestCase
test "uses default_url_options" do
original_default_url_options = ActionMailer::Base.default_url_options
ActionMailer::Base.default_url_options = { host: "hoost" }
blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpg")
message = Message.new(content: ActionText::Content.new.append_attachables(blob))
MessagesMailer.with(recipient: "test", message: message).notification.deliver_now
assert_select_email do
assert_select "#message-content img" do |imgs|
imgs.each { |img| assert_match %r"//hoost/", img["src"] }
end
end
ensure
ActionMailer::Base.default_url_options = original_default_url_options
end
end