mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
614e813161
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>
23 lines
799 B
Ruby
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
|