mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Include topics from subcategories in tracked list (#10850)
This commit is contained in:
parent
16daf3c986
commit
2ad7d98990
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user