FIX: Include topics from subcategories in tracked list (#10850)

This commit is contained in:
Penar Musaraj 2020-10-07 12:15:28 -04:00 committed by GitHub
parent 16daf3c986
commit 2ad7d98990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -400,6 +400,12 @@ class TopicQuery
SELECT cu.category_id FROM category_users cu
WHERE cu.user_id = :user_id AND cu.notification_level >= :tracking
)
OR topics.category_id IN (
SELECT c.id FROM categories c WHERE c.parent_category_id IN (
SELECT cd.category_id FROM category_users cd
WHERE cd.user_id = :user_id AND cd.notification_level >= :tracking
)
)
SQL
if SiteSetting.tagging_enabled

View File

@ -148,6 +148,20 @@ describe TopicQuery do
query = TopicQuery.new(user, filter: 'tracked').list_latest
expect(query.topics.length).to eq(2)
# includes subcategories of tracked categories
parentcat = Fabricate(:category)
subcat = Fabricate(:category, parent_category_id: parentcat.id)
topic3 = Fabricate(:topic, category_id: subcat.id)
CategoryUser.create!(
category_id: parentcat.id,
user_id: user.id,
notification_level: NotificationLevels.all[:tracking]
)
query = TopicQuery.new(user, filter: 'tracked').list_latest
expect(query.topics.length).to eq(3)
end
end