UX: Exclude child catgegories of muted category in similar to search (#19414)

Follow-up to 207b764ea3
This commit is contained in:
Alan Guo Xiang Tan
2022-12-12 06:31:46 +08:00
committed by GitHub
parent c9197cf9d8
commit 332ac0f299
2 changed files with 12 additions and 1 deletions

View File

@@ -701,6 +701,17 @@ RSpec.describe Topic do
expect(Topic.similar_to("has evil trout made any topics?", "", user)).to eq([])
end
it 'does not return topics from child categories where the user has muted the parent category' do
expect(Topic.similar_to("has evil trout made any topics?", "", user)).to eq([topic])
parent_category = topic.category
child_category = Fabricate(:category, parent_category: parent_category)
topic.update!(category: child_category)
CategoryUser.create!(category: parent_category, user: user, notification_level: CategoryUser.notification_levels[:muted])
expect(Topic.similar_to("has evil trout made any topics?", "", user)).to eq([])
end
context "with secure categories" do
fab!(:group) { Fabricate(:group) }
fab!(:private_category) { Fabricate(:private_category, group: group) }