13
13
let ( :per_page ) { response . headers [ 'Per-Page' ] . to_i }
14
14
15
15
context 'without enough items to give more than one page' do
16
- before { get :index , : count => 10 }
16
+ before { get :index , params : { count : 10 } }
17
17
18
18
it 'should not paginate' do
19
19
expect ( response . headers . keys ) . not_to include ( 'Link' )
34
34
end
35
35
36
36
context 'with existing Link headers' do
37
- before { get :index , : count => 30 , : with_headers => true }
37
+ before { get :index , params : { count : 30 , with_headers : true } }
38
38
39
39
it_behaves_like 'an endpoint with existing Link headers'
40
40
end
41
41
42
42
context 'with enough items to paginate' do
43
43
context 'when on the first page' do
44
- before { get :index , : count => 100 }
44
+ before { get :index , params : { count : 100 } }
45
45
46
46
it_behaves_like 'an endpoint with a first page'
47
47
end
48
48
49
49
context 'when on the last page' do
50
- before { get :index , : count => 100 , : page => 10 }
50
+ before { get :index , params : { count : 100 , page : 10 } }
51
51
52
52
it_behaves_like 'an endpoint with a last page'
53
53
end
54
54
55
55
context 'when somewhere comfortably in the middle' do
56
- before { get :index , : count => 100 , : page => 2 }
56
+ before { get :index , params : { count : 100 , page : 2 } }
57
57
58
58
it_behaves_like 'an endpoint with a middle page'
59
59
end
60
60
end
61
61
62
62
context 'providing a block' do
63
63
it 'yields to the block instead of implicitly rendering' do
64
- get :index_with_custom_render , : count => 100
64
+ get :index_with_custom_render , params : { count : 100 }
65
65
66
66
json = { numbers : ( 1 ..10 ) . map { |n | { number : n } } } . to_json
67
67
75
75
ApiPagination . config . per_page_header = 'X-Per-Page'
76
76
ApiPagination . config . page_header = 'X-Page'
77
77
78
- get :index , count : 10
78
+ get :index , params : { count : 10 }
79
79
end
80
80
81
81
after do
116
116
before { ApiPagination . config . include_total = false }
117
117
118
118
it 'should not include a Total header' do
119
- get :index , count : 10
119
+ get :index , params : { count : 10 }
120
120
121
121
expect ( response . header [ 'Total' ] ) . to be_nil
122
122
end
137
137
end
138
138
139
139
it 'should work' do
140
- get :index , : foo => 2 , : count => 100
140
+ get :index , params : { foo : 2 , count : 100 }
141
141
142
142
expect ( response . header [ 'Page' ] ) . to eq ( '2' )
143
143
end
158
158
end
159
159
160
160
it 'should work' do
161
- get :index , :foo => { : bar => 2 } , : count => 100
161
+ get :index , params : { foo : { bar : 2 } , count : 100 }
162
162
163
163
expect ( response . header [ 'Page' ] ) . to eq ( '2' )
164
164
end
176
176
end
177
177
178
178
it 'should work' do
179
- get :index_with_no_per_page , : foo => 2 , : count => 100
179
+ get :index_with_no_per_page , params : { foo : 2 , count : 100 }
180
180
181
181
expect ( response . header [ 'Per-Page' ] ) . to eq ( '2' )
182
182
end
194
194
end
195
195
196
196
it 'should work' do
197
- get :index_with_no_per_page , :foo => { : bar => 2 } , : count => 100
197
+ get :index_with_no_per_page , params : { foo : { bar : 2 } , count : 100 }
198
198
199
199
expect ( response . header [ 'Per-Page' ] ) . to eq ( '2' )
200
200
end
211
211
end
212
212
213
213
specify do
214
- get :index_with_paginate_array_options , params
214
+ get :index_with_paginate_array_options , params : params
215
215
expect ( response . header [ 'Total' ] . to_i ) . to eq total_header
216
216
end
217
217
end
@@ -267,7 +267,7 @@ class Fixnum
267
267
end
268
268
269
269
it 'should use default per page from model' do
270
- get :index_with_no_per_page , count : 100
270
+ get :index_with_no_per_page , params : { count : 100 }
271
271
272
272
expect ( response . header [ 'Per-Page' ] ) . to eq ( '6' )
273
273
end
@@ -278,7 +278,7 @@ class Fixnum
278
278
@per_page = nil
279
279
end
280
280
281
- get :index_with_no_per_page , count : 100
281
+ get :index_with_no_per_page , params : { count : 100 }
282
282
283
283
expect ( response . header [ 'Per-Page' ] ) . to eq (
284
284
case ApiPagination . config . paginator
0 commit comments