@@ -76,7 +76,7 @@ def last_page_links
76
76
}
77
77
end
78
78
79
- def expected_response_without_pagination_links
79
+ def expected_response_when_unpaginatable
80
80
data
81
81
end
82
82
@@ -87,6 +87,12 @@ def expected_response_with_pagination_links
87
87
end
88
88
end
89
89
90
+ def expected_response_without_pagination_links
91
+ { } . tap do |hash |
92
+ hash [ :data ] = data . values . flatten [ 2 ..3 ]
93
+ end
94
+ end
95
+
90
96
def expected_response_with_pagination_links_and_additional_params
91
97
new_links = links [ :links ] . each_with_object ( { } ) { |( key , value ) , hash | hash [ key ] = "#{ value } &test=test" }
92
98
{ } . tap do |hash |
@@ -159,7 +165,7 @@ def test_last_page_pagination_links_using_will_paginate
159
165
def test_not_showing_pagination_links
160
166
adapter = load_adapter ( @array , mock_request )
161
167
162
- assert_equal expected_response_without_pagination_links , adapter . serializable_hash
168
+ assert_equal expected_response_when_unpaginatable , adapter . serializable_hash
163
169
end
164
170
165
171
def test_raises_descriptive_error_when_serialization_context_unset
@@ -172,6 +178,15 @@ def test_raises_descriptive_error_when_serialization_context_unset
172
178
assert_equal exception_class , exception . class
173
179
assert_match ( /CollectionSerializer#paginated\? / , exception . message )
174
180
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
175
190
end
176
191
end
177
192
end
0 commit comments