From f3f9aec547f50ca3541962d2a0abc973e90647c2 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 9 Apr 2026 17:29:30 -0400 Subject: [PATCH] Fix missing partial when editing comments with @mentions (#2828) Edge Rails introduced ActionText::Attachable#to_editor_content_attachment_partial_path which defaults to to_partial_path ("users/user"). Override it in User::Mentionable to delegate to to_attachable_partial_path ("users/attachable"), matching the existing display rendering path. --- app/models/user/mentionable.rb | 4 ++++ .../cards/comments_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/models/user/mentionable.rb b/app/models/user/mentionable.rb index be82f3d95..87b2c0f21 100644 --- a/app/models/user/mentionable.rb +++ b/app/models/user/mentionable.rb @@ -8,6 +8,10 @@ module User::Mentionable def to_attachable_partial_path "users/attachable" end + + def to_editor_content_attachment_partial_path + to_attachable_partial_path + end end def mentioned_by(mentioner, at:) diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb index be5831e39..5cebe22de 100644 --- a/test/controllers/cards/comments_controller_test.rb +++ b/test/controllers/cards/comments_controller_test.rb @@ -113,6 +113,22 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest assert_equal "Updated comment", comment.reload.body.to_plain_text end + test "edit a comment that contains a mention" do + card = cards(:logo) + mentioned_user = users(:jz) + mention_html = ActionText::Attachment.from_attachable(mentioned_user).to_html + comment = card.comments.create!(creator: users(:kevin), body: "#{mention_html} hello") + + get edit_card_comment_path(card, comment) + assert_response :success + assert_select "lexxy-editor" do |editors| + value = editors.first["value"] + attachment = Nokogiri::HTML.fragment(value).at_css("action-text-attachment") + assert_equal mentioned_user.attachable_sgid, attachment["sgid"] + assert_includes attachment["content"], mentioned_user.first_name + end + end + test "destroy as JSON" do comment = comments(:logo_agreement_kevin)