Fix: extract mentions when publishing cards
This wasn't working when creation and publishing happened on separated instances of the same record, which is what happens when you edit a draft and then you publish it https://app.fizzy.do/5986089/cards/2835/edit
This commit is contained in:
@@ -7,5 +7,9 @@ module Card::Mentions
|
||||
def mentionable?
|
||||
published?
|
||||
end
|
||||
|
||||
def should_check_mentions?
|
||||
saved_change_to_status? && published?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user