mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Make sure topic_user.bookmarked is synced in more places (#13383)
When we call Bookmark.cleanup! we want to make sure that topic_user.bookmarked is updated for topics linked to the bookmarks that were deleted. Also when PostDestroyer calls destroy and recover. We have a job for this already -- SyncTopicUserBookmarked -- so we just utilize that.
This commit is contained in:
@@ -27,6 +27,24 @@ RSpec.describe Jobs::SyncTopicUserBookmarked do
|
||||
expect(tu5.reload.bookmarked).to eq(false)
|
||||
end
|
||||
|
||||
it "does not consider topic as bookmarked if the bookmarked post is deleted" do
|
||||
topic = Fabricate(:topic)
|
||||
post1 = Fabricate(:post, topic: topic)
|
||||
|
||||
tu1 = Fabricate(:topic_user, topic: topic, bookmarked: false)
|
||||
tu2 = Fabricate(:topic_user, topic: topic, bookmarked: true)
|
||||
|
||||
Fabricate(:bookmark, user: tu1.user, topic: topic, post: post1)
|
||||
Fabricate(:bookmark, user: tu2.user, topic: topic, post: post1)
|
||||
|
||||
post1.trash!
|
||||
|
||||
subject.execute(topic_id: topic.id)
|
||||
|
||||
expect(tu1.reload.bookmarked).to eq(false)
|
||||
expect(tu2.reload.bookmarked).to eq(false)
|
||||
end
|
||||
|
||||
it "works when no topic id is provided (runs for all topics)" do
|
||||
topic = Fabricate(:topic)
|
||||
Fabricate(:post, topic: topic)
|
||||
|
||||
Reference in New Issue
Block a user