Mint the tampered attachable sgid without extending a Room

The companion to #279: the same per-instance `extend` appeared in
test/lib/rails_ext/action_text_attachables_test.rb. `attachable_sgid` is
`to_sgid(expires_in: nil, for: ActionText::Attachable::LOCATOR_NAME).to_s`,
so mint that directly; the minted bytes and the assertion are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sam Ruby
2026-09-23 07:45:57 -04:00
committed by Rosa Gutierrez
parent 9ff6b4a381
commit 91d294f4a0
@@ -28,9 +28,11 @@ class ActionText::AttachmentTest < ActiveSupport::TestCase
end
test "from_node with an invalid SGID" do
room = rooms(:pets).tap { |r| r.extend ActionText::Attachable }
# A Room is not attachable; mint the sgid an attachable would carry
# (`ActionText::Attachable#attachable_sgid` is exactly this call).
sgid = rooms(:pets).to_sgid(expires_in: nil, for: ActionText::Attachable::LOCATOR_NAME).to_s
html = %Q(<action-text-attachment sgid="#{room.attachable_sgid}invalid"></action-text-attachment>)
html = %Q(<action-text-attachment sgid="#{sgid}invalid"></action-text-attachment>)
node = ActionText::Fragment.wrap(html).find_all(ActionText::Attachment.tag_name).first
attachment = ActionText::Attachment.from_node(node)