mirror of
https://github.com/discourse/discourse.git
synced 2026-07-31 16:48:26 -05:00
FIX: Add a page limit to directory_items endpoint (#37496)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
class DirectoryItemsController < ApplicationController
|
||||
PAGE_SIZE = 50
|
||||
PAGE_LIMIT = 10
|
||||
|
||||
before_action :set_groups_exclusion, if: -> { params[:exclude_groups].present? }
|
||||
|
||||
def index
|
||||
@@ -58,7 +60,7 @@ class DirectoryItemsController < ApplicationController
|
||||
end
|
||||
|
||||
result = result.includes(:user_stat) if period_type == DirectoryItem.period_types[:all]
|
||||
page = fetch_int_from_params(:page, default: 0)
|
||||
page = fetch_int_from_params(:page, default: 0, max: PAGE_LIMIT)
|
||||
|
||||
user_ids = nil
|
||||
if params[:name].present?
|
||||
|
||||
@@ -43,6 +43,11 @@ RSpec.describe DirectoryItemsController do
|
||||
get "/directory_items.json", params: { period: "all", page: 0 }
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "has a page number limit" do
|
||||
get "/directory_items.json", params: { period: "all", page: described_class::PAGE_LIMIT + 1 }
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
end
|
||||
|
||||
context "with exclude_groups parameter" do
|
||||
|
||||
Reference in New Issue
Block a user