mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Support status:public in topics filtering query language (#20889)
This commit adds support for the `status:public` filter which only return topics that belong to public categories.
This commit is contained in:
committed by
GitHub
parent
f8ff97b2ec
commit
4e11014693
@@ -2,6 +2,7 @@
|
||||
|
||||
RSpec.describe TopicsFilter do
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
|
||||
describe "#filter_from_query_string" do
|
||||
describe "when filtering with multiple filters" do
|
||||
@@ -87,6 +88,22 @@ RSpec.describe TopicsFilter do
|
||||
.pluck(:id),
|
||||
).to contain_exactly(topic.id)
|
||||
end
|
||||
|
||||
it "should only return topics that are not in any read-restricted category when query string is `status:public`" do
|
||||
private_category = Fabricate(:private_category, group: group)
|
||||
topic_in_private_category = Fabricate(:topic, category: private_category)
|
||||
|
||||
expect(
|
||||
TopicsFilter.new(guardian: Guardian.new).filter_from_query_string("").pluck(:id),
|
||||
).to include(topic_in_private_category.id)
|
||||
|
||||
expect(
|
||||
TopicsFilter
|
||||
.new(guardian: Guardian.new)
|
||||
.filter_from_query_string("status:public")
|
||||
.pluck(:id),
|
||||
).not_to include(topic_in_private_category.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when filtering by tags" do
|
||||
|
||||
Reference in New Issue
Block a user