@@ -90,6 +90,18 @@ def last_page_links
90
90
}
91
91
end
92
92
93
+ def greater_than_last_page_links
94
+ {
95
+ links : {
96
+ self : "#{ URI } ?page%5Bnumber%5D=4&page%5Bsize%5D=2" ,
97
+ first : "#{ URI } ?page%5Bnumber%5D=1&page%5Bsize%5D=2" ,
98
+ prev : "#{ URI } ?page%5Bnumber%5D=3&page%5Bsize%5D=2" ,
99
+ next : nil ,
100
+ last : "#{ URI } ?page%5Bnumber%5D=3&page%5Bsize%5D=2"
101
+ }
102
+ }
103
+ end
104
+
93
105
def expected_response_when_unpaginatable
94
106
data
95
107
end
@@ -122,6 +134,13 @@ def expected_response_with_last_page_pagination_links
122
134
end
123
135
end
124
136
137
+ def expected_response_with_greater_than_last_page_pagination_links
138
+ { } . tap do |hash |
139
+ hash [ :data ] = [ ]
140
+ hash . merge! greater_than_last_page_links
141
+ end
142
+ end
143
+
125
144
def expected_response_with_empty_collection_pagination_links
126
145
{ } . tap do |hash |
127
146
hash [ :data ] = [ ]
@@ -141,6 +160,18 @@ def test_pagination_links_using_will_paginate
141
160
assert_equal expected_response_with_pagination_links , adapter . serializable_hash
142
161
end
143
162
163
+ def test_pagination_links_invalid_current_page_using_kaminari
164
+ adapter = load_adapter ( using_kaminari ( 4 ) , mock_request )
165
+
166
+ assert_equal expected_response_with_greater_than_last_page_pagination_links , adapter . serializable_hash
167
+ end
168
+
169
+ def test_pagination_links_invalid_current_page_using_will_paginate
170
+ adapter = load_adapter ( using_will_paginate ( 4 ) , mock_request )
171
+
172
+ assert_equal expected_response_with_greater_than_last_page_pagination_links , adapter . serializable_hash
173
+ end
174
+
144
175
def test_pagination_links_with_additional_params
145
176
adapter = load_adapter ( using_will_paginate , mock_request ( test : 'test' ) )
146
177
0 commit comments