1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

make sure rendering the content attachment actually works

This commit is contained in:
Jamis Buck 2022-08-04 10:07:23 -06:00
parent 9918ce4a78
commit 5f342cfdbe
2 changed files with 11 additions and 1 deletions

View file

@ -20,7 +20,7 @@ module ActionText
end
def to_html
@to_html ||= content_instance.render
@to_html ||= content_instance.render(content_instance)
end
def to_s

View file

@ -69,6 +69,16 @@ class ActionText::AttachmentTest < ActiveSupport::TestCase
assert_equal "abc", trix_attachment.attributes["content"]
end
test "renders content attachment" do
html = '<action-text-attachment content-type="text/html" content="&lt;p&gt;abc&lt;/p&gt;"></action-text-attachment>'
attachment = attachment_from_html(html)
attachable = attachment.attachable
ActionText::Content.with_renderer MessagesController.renderer do
assert_equal "<p>abc</p>", attachable.to_html.strip
end
end
test "defaults trix partial to model partial" do
attachable = Page.create! title: "Homepage"
assert_equal "pages/page", attachable.to_trix_content_attachment_partial_path