mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Notify tag watchers when publishing topic (#17576)
When a topic was published from a shared draft and it had tags, the users watching the tags were not notified. The problem was that the topics are usually created in a secret category and publishing it just moves an existent topic to the target category, without making any changes to the tags.
This commit is contained in:
@@ -16,6 +16,8 @@ describe TopicPublisher do
|
||||
fab!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) }
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
fab!(:op) { Fabricate(:post, topic: topic) }
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
|
||||
before do
|
||||
# Create a revision
|
||||
@@ -51,6 +53,24 @@ describe TopicPublisher do
|
||||
expect(op.last_version_at).to eq_time(published_at)
|
||||
end
|
||||
end
|
||||
|
||||
it "will notify users watching tag" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
TagUser.create!(
|
||||
user_id: user.id,
|
||||
tag_id: tag.id,
|
||||
notification_level: NotificationLevels.topic_levels[:watching]
|
||||
)
|
||||
|
||||
topic.update!(tags: [tag])
|
||||
|
||||
expect { TopicPublisher.new(topic, moderator, shared_draft.category_id).publish! }
|
||||
.to change { Notification.count }.by(1)
|
||||
|
||||
topic.reload
|
||||
expect(topic.tags).to contain_exactly(tag)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user