mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-04 22:03:40 +09:00
Rebuild every attachment before editing a message
The editor keeps an attachment's content as it finds it, so a hand-written embed with a url but no href reached the editor with its markup unvalidated, and a mention saved under Trix's editor carried the generic octet-stream content type the editor doesn't permit and was dropped on save. Rebuilding each attachment from its attachable renders the hardened preview partial and restores the mention content type.
This commit is contained in:
@@ -86,6 +86,34 @@ class ComposerTest < ApplicationSystemTestCase
|
||||
assert_equal [ users(:jason) ], message.reload.mentionees
|
||||
end
|
||||
|
||||
test "editing a message whose mention was saved under Trix keeps the mention" do
|
||||
body = %(<div>Hey <action-text-attachment sgid="#{users(:jason).attachable_sgid}" content-type="application/octet-stream"></action-text-attachment></div>)
|
||||
message = Message.create! room: rooms(:designers), body: body, client_message_id: "trix-edited", creator: users(:jz)
|
||||
|
||||
join_room rooms(:designers)
|
||||
|
||||
within_message message do
|
||||
reveal_message_actions
|
||||
find(".message__edit-btn").click
|
||||
assert_edit_editor_text "Jason"
|
||||
click_on "Save changes"
|
||||
end
|
||||
|
||||
assert_selector last_message_selector(".mention"), text: "Jason"
|
||||
assert_equal [ users(:jason) ], message.reload.mentionees
|
||||
end
|
||||
|
||||
test "pasting a table keeps its text" do
|
||||
paste_in_composer "Name Points\nJason 10", html: "<table><tr><th>Name</th><th>Points</th></tr><tr><td>Jason</td><td>10</td></tr></table>"
|
||||
|
||||
assert_selector "#composer lexxy-editor table"
|
||||
|
||||
click_send_button
|
||||
|
||||
assert_message_text /Name Points\s*Jason 10/
|
||||
assert_no_selector last_message_selector("table")
|
||||
end
|
||||
|
||||
test "replying quotes the original message with attribution" do
|
||||
within_message messages(:third) do
|
||||
reveal_message_actions
|
||||
|
||||
Reference in New Issue
Block a user