@@ -76,7 +76,7 @@ def last_page_links
7676 }
7777 end
7878
79- def expected_response_without_pagination_links
79+ def expected_response_when_unpaginatable
8080 data
8181 end
8282
@@ -87,6 +87,12 @@ def expected_response_with_pagination_links
8787 end
8888 end
8989
90+ def expected_response_without_pagination_links
91+ { } . tap do |hash |
92+ hash [ :data ] = data . values . flatten [ 2 ..3 ]
93+ end
94+ end
95+
9096 def expected_response_with_pagination_links_and_additional_params
9197 new_links = links [ :links ] . each_with_object ( { } ) { |( key , value ) , hash | hash [ key ] = "#{ value } &test=test" }
9298 { } . tap do |hash |
@@ -159,7 +165,7 @@ def test_last_page_pagination_links_using_will_paginate
159165 def test_not_showing_pagination_links
160166 adapter = load_adapter ( @array , mock_request )
161167
162- assert_equal expected_response_without_pagination_links , adapter . serializable_hash
168+ assert_equal expected_response_when_unpaginatable , adapter . serializable_hash
163169 end
164170
165171 def test_raises_descriptive_error_when_serialization_context_unset
@@ -172,6 +178,15 @@ def test_raises_descriptive_error_when_serialization_context_unset
172178 assert_equal exception_class , exception . class
173179 assert_match ( /CollectionSerializer#paginated\? / , exception . message )
174180 end
181+
182+ def test_pagination_links_not_present_when_disabled
183+ ActiveModel ::Serializer . config . jsonapi_pagination_links_enabled = false
184+ adapter = load_adapter ( using_kaminari , mock_request )
185+
186+ assert_equal expected_response_without_pagination_links , adapter . serializable_hash
187+ ensure
188+ ActiveModel ::Serializer . config . jsonapi_pagination_links_enabled = true
189+ end
175190 end
176191 end
177192 end
0 commit comments