diff --git a/app/models/card/mentions.rb b/app/models/card/mentions.rb index cb3a34f17..3ce74726b 100644 --- a/app/models/card/mentions.rb +++ b/app/models/card/mentions.rb @@ -7,5 +7,9 @@ module Card::Mentions def mentionable? published? end + + def should_check_mentions? + saved_change_to_status? && published? + end end end diff --git a/app/models/concerns/mentions.rb b/app/models/concerns/mentions.rb index 055c114fc..a412fac69 100644 --- a/app/models/concerns/mentions.rb +++ b/app/models/concerns/mentions.rb @@ -49,7 +49,7 @@ module Mentions end def should_create_mentions? - mentionable? && mentionable_content_changed? + mentionable? && (mentionable_content_changed? || should_check_mentions?) end def mentionable_content_changed? @@ -64,4 +64,8 @@ module Mentions def mentionable? true end + + def should_check_mentions? + false + end end diff --git a/test/models/concerns/mentions_test.rb b/test/models/concerns/mentions_test.rb index d2edb073a..92cf95e1c 100644 --- a/test/models/concerns/mentions_test.rb +++ b/test/models/concerns/mentions_test.rb @@ -20,6 +20,8 @@ class MentionsTest < ActiveSupport::TestCase boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, @david?" end + card = Card.find(card.id) + assert_difference -> { Mention.count }, +1 do card.published! end @@ -33,6 +35,8 @@ class MentionsTest < ActiveSupport::TestCase boards(:writebook).cards.create title: "Cleanup", description: "Did you finish up with the cleanup, #{attachment.to_html}?" end + card = Card.find(card.id) + assert_difference -> { Mention.count }, +1 do card.published! end