Fix ActiveStorage::Blob → ActionText::TrixAttachment conversion

A regression introduced in 764803e07a caused blobs to appear as HTML content attachments instead of file / image attachments when editing rich text content. This change restores the original intended behavior.

References: https://github.com/rails/rails/pull/35485, https://github.com/basecamp/trix/issues/706
This commit is contained in:
Javan Makhmali 2019-12-03 05:57:36 -05:00
parent f7342780c1
commit 296cc53277
2 changed files with 6 additions and 2 deletions

View File

@ -29,6 +29,10 @@ module ActionText
def attachable_plain_text_representation(caption = nil)
"[#{caption || filename}]"
end
def to_trix_content_attachment_partial_path
nil
end
end
end

View File

@ -32,8 +32,8 @@ class ActionText::AttachmentTest < ActiveSupport::TestCase
assert_equal attachable.byte_size, trix_attachment.attributes["filesize"]
assert_equal "Captioned", trix_attachment.attributes["caption"]
assert_not_nil attachable.to_trix_content_attachment_partial_path
assert_not_nil trix_attachment.attributes["content"]
assert_nil attachable.to_trix_content_attachment_partial_path
assert_nil trix_attachment.attributes["content"]
end
test "converts to TrixAttachment with content" do