Remove plain text mentions
They can cause duplicates https://app.fizzy.do/5986089/cards/2874 Closes #https://github.com/basecamp/fizzy/pull/1549
This commit is contained in:
@@ -8,8 +8,8 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
test "don't create mentions when creating or updating drafts" do
|
||||
assert_no_difference -> { Mention.count } do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, @david?"
|
||||
card.update description: "Any thoughts here @jz"
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{mention_html_for(users(:david))}?"
|
||||
card.update description: "Any thoughts here #{mention_html_for(users(:jz))}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,7 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
test "create mentions from plain text mentions when publishing cards" do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
card = assert_no_difference -> { Mention.count } do
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, @david?"
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{mention_html_for(users(:david))}?"
|
||||
end
|
||||
|
||||
card = Card.find(card.id)
|
||||
@@ -31,8 +31,7 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
test "create mentions from rich text mentions when publishing cards" do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
card = assert_no_difference -> { Mention.count } do
|
||||
attachment = ActionText::Attachment.from_attachable(users(:david))
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{attachment.to_html}?"
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{mention_html_for(users(:david))}?"
|
||||
end
|
||||
|
||||
card = Card.find(card.id)
|
||||
@@ -45,18 +44,18 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
|
||||
test "don't create repeated mentions when updating cards" do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, @david?"
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{mention_html_for(users(:david))}?"
|
||||
|
||||
assert_difference -> { Mention.count }, +1 do
|
||||
card.published!
|
||||
end
|
||||
|
||||
assert_no_difference -> { Mention.count } do
|
||||
card.update description: "Any thoughts here @david"
|
||||
card.update description: "Any thoughts here #{mention_html_for(users(:david))}"
|
||||
end
|
||||
|
||||
assert_difference -> { Mention.count }, +1 do
|
||||
card.update description: "Any thoughts here @jz"
|
||||
card.update description: "Any thoughts here #{mention_html_for(users(:jz))}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -66,7 +65,7 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Some initial content", status: :published
|
||||
|
||||
assert_difference -> { Mention.count }, +1 do
|
||||
card.comments.create!(body: "Great work on this @david!")
|
||||
card.comments.create!(body: "Great work on this #{mention_html_for(users(:david))}!")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -76,7 +75,7 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Some initial content"
|
||||
|
||||
assert_no_difference -> { Mention.count } do
|
||||
card.comments.create!(body: "Great work on this @david!")
|
||||
card.comments.create!(body: "Great work on this #{mention_html_for(users(:david))}!")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -87,17 +86,21 @@ class MentionsTest < ActiveSupport::TestCase
|
||||
|
||||
assert_no_difference -> { Mention.count }, +1 do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
attachment = ActionText::Attachment.from_attachable(users(:david))
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{attachment.to_html}?"
|
||||
boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{mention_html_for(users(:david))}?"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "mentionees are added as watchers of the card" do
|
||||
perform_enqueued_jobs only: Mention::CreateJob do
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup @kevin?"
|
||||
card = boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup #{mention_html_for(users(:kevin))}?"
|
||||
card.published!
|
||||
assert card.watchers.include?(users(:kevin))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def mention_html_for(user)
|
||||
ActionText::Attachment.from_attachable(user).to_html
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user