From 296cc5327782a03b4df4c68b17d9b33d216f8e93 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Tue, 3 Dec 2019 05:57:36 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20ActiveStorage::Blob=20=E2=86=92=20ActionT?= =?UTF-8?q?ext::TrixAttachment=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A regression introduced in 764803e07a5c89c931df9a1c4fe730f73b7571e6 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 --- actiontext/lib/action_text/engine.rb | 4 ++++ actiontext/test/unit/attachment_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actiontext/lib/action_text/engine.rb b/actiontext/lib/action_text/engine.rb index 0f55d460a1..8749498158 100644 --- a/actiontext/lib/action_text/engine.rb +++ b/actiontext/lib/action_text/engine.rb @@ -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 diff --git a/actiontext/test/unit/attachment_test.rb b/actiontext/test/unit/attachment_test.rb index 54831a0271..9ed1967450 100644 --- a/actiontext/test/unit/attachment_test.rb +++ b/actiontext/test/unit/attachment_test.rb @@ -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