Commit 8e71bd07 authored by Andreas Brandl's avatar Andreas Brandl

Maximum page size to 100 for API keyset pagination

This aligns with offset pagination, where we also allow up to 100
records max.
parent 88d33022
......@@ -5,9 +5,12 @@ module Gitlab
module Keyset
# A Page models the pagination information for a particular page of the collection
class Page
# Default and maximum size of records for a page
# Default number of records for a page
DEFAULT_PAGE_SIZE = 20
# Maximum number of records for a page
MAXIMUM_PAGE_SIZE = 100
attr_accessor :lower_bounds, :end_reached
attr_reader :order_by
......@@ -22,7 +25,7 @@ module Gitlab
def per_page
return DEFAULT_PAGE_SIZE if @per_page <= 0
[@per_page, DEFAULT_PAGE_SIZE].min
[@per_page, MAXIMUM_PAGE_SIZE].min
end
# Determine whether this page indicates the end of the collection
......
......@@ -4,10 +4,10 @@ require 'spec_helper'
describe Gitlab::Pagination::Keyset::Page do
describe '#per_page' do
it 'limits to a maximum of 20 records per page' do
per_page = described_class.new(per_page: 21).per_page
it 'limits to a maximum of 100 records per page' do
per_page = described_class.new(per_page: 101).per_page
expect(per_page).to eq(described_class::DEFAULT_PAGE_SIZE)
expect(per_page).to eq(described_class::MAXIMUM_PAGE_SIZE)
end
it 'uses default value when given 0' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment