pagination: refactor page limits.
Refactor page limits to a) be explicitly listed in the User class (not hidden away in the Danbooru config) and b) explicitly depend on the CurrentUser (not implicitly by way of Danbooru.config.max_numbered_pages).
This commit is contained in:
@@ -3,6 +3,11 @@ require 'test_helper'
|
||||
class PaginatorTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@posts = FactoryBot.create_list(:post, 5)
|
||||
CurrentUser.user = User.anonymous
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
context "sequential pagination (before)" do
|
||||
@@ -37,9 +42,8 @@ class PaginatorTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "raise an error when exceeding the page limit" do
|
||||
Danbooru.config.stubs(:max_numbered_pages).returns(5)
|
||||
assert_raises(PaginationExtension::PaginationError) do
|
||||
Post.paginate(10)
|
||||
Post.paginate(10, page_limit: 5)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user