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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user