FIX: mark topics in sub categories as unread when dismissing parent

Previously we would only dismiss the parent category and leave the
child categories unread
This commit is contained in:
Sam Saffron
2019-06-27 13:26:07 +10:00
parent 79d657203d
commit 5bc5c02af6
6 changed files with 54 additions and 14 deletions

View File

@ -2039,6 +2039,27 @@ RSpec.describe TopicsController do
expect(response.status).to eq(400)
end
it "can mark sub-categories unread" do
# TODO do we want to skip category definition by default in fabricator
category = Fabricate(:category, skip_category_definition: true)
sub = Fabricate(:category, parent_category_id: category.id, skip_category_definition: true)
topic.update!(category_id: sub.id)
post1 = create_post(user: user, topic_id: topic.id)
create_post(topic_id: topic.id)
put "/topics/bulk.json", params: {
category_id: category.id,
include_subcategories: true,
filter: 'unread',
operation: { type: 'dismiss_posts' }
}
expect(response.status).to eq(200)
expect(TopicUser.get(post1.topic, post1.user).last_read_post_number).to eq(2)
end
it "can find unread" do
# mark all unread muted
put "/topics/bulk.json", params: {