FEATURE: Allow `/filter` route to be accessible by anon users (#24359)

Why this change?

There is no reason for us to exclude anon users from viewing this route
so we're making a product decision to change this.
This commit is contained in:
Alan Guo Xiang Tan 2023-11-14 08:03:24 +08:00 committed by GitHub
parent a238f66b33
commit e5b0493b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -46,6 +46,7 @@ class ListController < ApplicationController
TopTopic.periods.map { |p| :"category_top_#{p}" },
TopTopic.periods.map { |p| :"category_none_top_#{p}" },
:group_topics,
:filter,
].flatten
# Create our filters

View File

@ -1160,10 +1160,14 @@ RSpec.describe ListController do
).to contain_exactly(topic.id)
end
it "should respond with 403 response code for an anonymous user" do
it "should not return topics that an anon user is not allowed to view" do
get "/filter.json"
expect(response.status).to eq(403)
expect(response.status).to eq(200)
expect(
response.parsed_body["topic_list"]["topics"].map { |topic| topic["id"] },
).to contain_exactly(topic.id)
end
it "should respond with 404 response code when `experimental_topics_filter` site setting has not been enabled" do