A platform for community discussion. Free, open, simple.
FIX: `/filter` route with `users` filter not loading more topics correctly (#36954)
Alan Guo Xiang Tanf1f09c375a1a
diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rbindex 08706302a08..0fffa3275ee 100644--- a/app/controllers/list_controller.rb+++ b/app/controllers/list_controller.rb@@ -483,9 +483,13 @@ class ListController < ApplicationControllerurl = public_send(method, opts.merge(page_params)).sub(".json?", "?")# Unicode usernames need to be encoded when calling Rails' path helper. However, it means that the already- # encoded username are encoded again which we do not want. As such, we unencode the url once when unicode usernames+ # encoded username are encoded again which we do not want. As such, we unencode the path once when unicode usernames# have been enabled.- url = UrlHelper.unencode(url) if SiteSetting.unicode_usernames+ if SiteSetting.unicode_usernames+ uri = URI.parse(url)+ uri.path = UrlHelper.unencode(uri.path)+ url = uri.to_s+ endurlenddiff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex 98427ed2008..c4dc8642ebd 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -1359,6 +1359,7 @@ RSpec.describe ListController dofab!(:private_category) { Fabricate(:private_category, group:, slug: "private-category-slug") }fab!(:private_message_topic)fab!(:topic_in_private_category) { Fabricate(:topic, category: private_category) }+ fab!(:user2, :user)it "should not return topics that the user is not allowed to view" dosign_in(user)@@ -1443,6 +1444,30 @@ RSpec.describe ListController doendend+ it "keeps query params encoded in more_topics_url when unicode usernames are enabled" do+ SiteSetting.unicode_usernames = true++ topic_1 = Fabricate(:topic)+ Fabricate(:post, topic: topic_1, user: user)+ Fabricate(:post, topic: topic_1, user: user2)++ topic_2 = Fabricate(:topic)+ Fabricate(:post, topic: topic_2, user: user)+ Fabricate(:post, topic: topic_2, user: user2)++ stub_const(TopicQuery, "DEFAULT_PER_PAGE_COUNT", 1) do+ sign_in(user)++ get "/filter.json", params: { q: "users:#{user.username}+#{user2.username}" }++ expect(response.status).to eq(200)++ expect(response.parsed_body["topic_list"]["more_topics_url"]).to eq(+ "/filter?no_definitions=true&page=1&q=users%3A#{user.username}%2B#{user2.username}",+ )+ end+ end+it "should include filter_option_info in the response" doget "/filter.json"parsed = response.parsed_body