Resolve assertion error with LimitOffsetPagination and erronous parameters. Closes #2920.

This commit is contained in:
Tom Christie 2015-07-23 12:41:35 +01:00
parent 762a30dbda
commit 22631c73a7
2 changed files with 8 additions and 0 deletions

View File

@ -419,6 +419,8 @@ class LimitOffsetPagination(BasePagination):
_divide_with_ceil(self.count - self.offset, self.limit) +
_divide_with_ceil(self.offset, self.limit)
)
if current > final:
current = final
def page_number_to_url(page_number):
if page_number == 1:

View File

@ -435,6 +435,12 @@ class TestLimitOffset:
]
}
def test_erronous_offset(self):
request = Request(factory.get('/', {'limit': 5, 'offset': 1000}))
queryset = self.paginate_queryset(request)
self.get_paginated_content(queryset)
self.get_html_context()
def test_invalid_offset(self):
"""
An invalid offset query param should be treated as 0.