mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Merge pull request #1700 from iamnader/master
Support pagination link for Kaminari when no data is returned
This commit is contained in:
@@ -101,6 +101,13 @@ module ActiveModelSerializers
|
||||
end
|
||||
end
|
||||
|
||||
def expected_response_with_no_data_pagination_links
|
||||
{}.tap do |hash|
|
||||
hash[:data] = []
|
||||
hash[:links] = {}
|
||||
end
|
||||
end
|
||||
|
||||
def test_pagination_links_using_kaminari
|
||||
adapter = load_adapter(using_kaminari, mock_request)
|
||||
|
||||
@@ -120,6 +127,22 @@ module ActiveModelSerializers
|
||||
adapter.serializable_hash
|
||||
end
|
||||
|
||||
def test_pagination_links_when_zero_results_kaminari
|
||||
@array = []
|
||||
|
||||
adapter = load_adapter(using_kaminari(1), mock_request)
|
||||
|
||||
assert_equal expected_response_with_no_data_pagination_links, adapter.serializable_hash
|
||||
end
|
||||
|
||||
def test_pagination_links_when_zero_results_will_paginate
|
||||
@array = []
|
||||
|
||||
adapter = load_adapter(using_will_paginate(1), mock_request)
|
||||
|
||||
assert_equal expected_response_with_no_data_pagination_links, adapter.serializable_hash
|
||||
end
|
||||
|
||||
def test_last_page_pagination_links_using_kaminari
|
||||
adapter = load_adapter(using_kaminari(3), mock_request)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user