FIX: Load more users URL respect group param (#13485)

FIX: Load more users URL respect group param (#13485)

diff --git a/app/controllers/directory_items_controller.rb b/app/controllers/directory_items_controller.rb
index b8ec391..abfe46e 100644
--- a/app/controllers/directory_items_controller.rb
+++ b/app/controllers/directory_items_controller.rb
@@ -74,7 +74,7 @@ class DirectoryItemsController < ApplicationController
     result_count = result.count
     result = result.limit(PAGE_SIZE).offset(PAGE_SIZE * page).to_a
 
-    more_params = params.slice(:period, :order, :asc).permit!
+    more_params = params.slice(:period, :order, :asc, :group).permit!
     more_params[:page] = page + 1
     load_more_uri = URI.parse(directory_items_path(more_params))
     load_more_directory_items_json = "#{load_more_uri.path}.json?#{load_more_uri.query}"
diff --git a/spec/requests/directory_items_controller_spec.rb b/spec/requests/directory_items_controller_spec.rb
index 3fc5a43..d61ef2a 100644
--- a/spec/requests/directory_items_controller_spec.rb
+++ b/spec/requests/directory_items_controller_spec.rb
@@ -53,6 +53,16 @@ describe DirectoryItemsController do
       expect(json['meta']['load_more_directory_items']).to include('.json')
     end
 
+    it "respects more_params in load_more_directory_items" do
+      get '/directory_items.json', params: { period: 'all', order: "likes_given", group: group.name }
+      expect(response.status).to eq(200)
+      json = response.parsed_body
+
+      expect(json['meta']['load_more_directory_items']).to include("group=#{group.name}")
+      expect(json['meta']['load_more_directory_items']).to include("order=likes_given")
+      expect(json['meta']['load_more_directory_items']).to include("period=all")
+    end
+
     it "fails when the directory is disabled" do
       SiteSetting.enable_user_directory = false
 

GitHub sha: 18de11f3a6f2970a3c986373f220da40b0ed006d

This commit appears in #13485 which was approved by pmusaraj. It was merged by markvanlan.