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.
This commit is contained in:
Mike Dalessio
2026-04-09 17:29:30 -04:00
committed by GitHub
parent 56f47361f9
commit f3f9aec547
2 changed files with 20 additions and 0 deletions
+4
View File
@@ -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:)
@@ -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)