Disable pagination links via config

This commit is contained in:
Lee Richmond
2016-09-06 13:28:09 -04:00
parent 050060478d
commit 19b5abf66e
4 changed files with 21 additions and 3 deletions

View File

@@ -76,7 +76,7 @@ module ActiveModelSerializers
}
end
def expected_response_without_pagination_links
def expected_response_when_unpaginatable
data
end
@@ -87,6 +87,12 @@ module ActiveModelSerializers
end
end
def expected_response_without_pagination_links
{}.tap do |hash|
hash[:data] = data.values.flatten[2..3]
end
end
def expected_response_with_pagination_links_and_additional_params
new_links = links[:links].each_with_object({}) { |(key, value), hash| hash[key] = "#{value}&test=test" }
{}.tap do |hash|
@@ -159,7 +165,7 @@ module ActiveModelSerializers
def test_not_showing_pagination_links
adapter = load_adapter(@array, mock_request)
assert_equal expected_response_without_pagination_links, adapter.serializable_hash
assert_equal expected_response_when_unpaginatable, adapter.serializable_hash
end
def test_raises_descriptive_error_when_serialization_context_unset
@@ -172,6 +178,15 @@ module ActiveModelSerializers
assert_equal exception_class, exception.class
assert_match(/CollectionSerializer#paginated\?/, exception.message)
end
def test_pagination_links_not_present_when_disabled
ActiveModel::Serializer.config.jsonapi_pagination_links_enabled = false
adapter = load_adapter(using_kaminari, mock_request)
assert_equal expected_response_without_pagination_links, adapter.serializable_hash
ensure
ActiveModel::Serializer.config.jsonapi_pagination_links_enabled = true
end
end
end
end