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/controller_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

24 lines
865 B
Ruby

# frozen_string_literal: true
require "test_helper"
class ActionText::ControllerRenderTest < ActionDispatch::IntegrationTest
test "uses current request environment" do
blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpg")
message = Message.create!(content: ActionText::Content.new.append_attachables(blob))
host! "loocalhoost"
get message_path(message)
assert_select "#content img" do |imgs|
imgs.each { |img| assert_match %r"//loocalhoost/", img["src"] }
end
end
test "resolves partials when controller is namespaced" do
blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpg")
message = Message.create!(content: ActionText::Content.new.append_attachables(blob))
get admin_message_path(message)
assert_select "#content-html .trix-content .attachment--jpg"
end
end