DEV: Remove experimental support for query string on /filter route (#20632)

This commit is contained in:
Alan Guo Xiang Tan
2023-03-22 10:04:57 +08:00
committed by GitHub
parent 520d4f504b
commit b06e31f8e7
11 changed files with 92 additions and 100 deletions

View File

@@ -9,41 +9,37 @@ RSpec.describe TopicsFilter do
describe "#filter" do
it "should return all topics when input is blank" do
expect(TopicsFilter.new(guardian: Guardian.new).filter("").pluck(:id)).to contain_exactly(
expect(TopicsFilter.new(guardian: Guardian.new).filter.pluck(:id)).to contain_exactly(
topic.id,
closed_topic.id,
archived_topic.id,
)
end
it "should return all topics when input does not match any filters" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter("randomstring").pluck(:id),
).to contain_exactly(topic.id, closed_topic.id, archived_topic.id)
end
context "when filtering by topic's status" do
it "should only return topics that have not been closed or archived when input is `status:open`" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter(status: "open").pluck(:id),
).to contain_exactly(topic.id)
end
it "should only return topics that have not been closed or archived when input is `status:open`" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter("status:open").pluck(:id),
).to contain_exactly(topic.id)
end
it "should only return topics that have been deleted when input is `status:deleted` and user can see deleted topics" do
expect(
TopicsFilter.new(guardian: Guardian.new(admin)).filter(status: "deleted").pluck(:id),
).to contain_exactly(deleted_topic_id)
end
it "should only return topics that have been deleted when input is `status:deleted` and user can see deleted topics" do
expect(
TopicsFilter.new(guardian: Guardian.new(admin)).filter("status:deleted").pluck(:id),
).to contain_exactly(deleted_topic_id)
end
it "should status filter when input is `status:deleted` and user cannot see deleted topics" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter(status: "deleted").pluck(:id),
).to contain_exactly(topic.id, closed_topic.id, archived_topic.id)
end
it "should status filter when input is `status:deleted` and user cannot see deleted topics" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter("status:deleted").pluck(:id),
).to contain_exactly(topic.id, closed_topic.id, archived_topic.id)
end
it "should only return topics that have been archived when input is `status:archived`" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter("status:archived").pluck(:id),
).to contain_exactly(archived_topic.id)
it "should only return topics that have been archived when input is `status:archived`" do
expect(
TopicsFilter.new(guardian: Guardian.new).filter(status: "archived").pluck(:id),
).to contain_exactly(archived_topic.id)
end
end
end
end