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

This commit is contained in:
Mark VanLandingham 2021-06-23 10:21:53 -05:00 committed by GitHub
parent cfc60f41f0
commit 18de11f3a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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}"

View File

@ -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