@@ -90,6 +90,18 @@ def last_page_links
9090 }
9191 end
9292
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+
93105 def expected_response_when_unpaginatable
94106 data
95107 end
@@ -122,6 +134,13 @@ def expected_response_with_last_page_pagination_links
122134 end
123135 end
124136
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+
125144 def expected_response_with_empty_collection_pagination_links
126145 { } . tap do |hash |
127146 hash [ :data ] = [ ]
@@ -141,6 +160,18 @@ def test_pagination_links_using_will_paginate
141160 assert_equal expected_response_with_pagination_links , adapter . serializable_hash
142161 end
143162
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+
144175 def test_pagination_links_with_additional_params
145176 adapter = load_adapter ( using_will_paginate , mock_request ( test : 'test' ) )
146177
0 commit comments