File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 7
7
schema : 'support/active_record/schema'
8
8
)
9
9
10
- describe 'using kaminari with active_record ' do
10
+ shared_examples 'produces_correct_sql ' do
11
11
let ( :collection ) { Foo . all }
12
12
let ( :per_page ) { 5 }
13
13
14
14
it 'produces correct sql for first page' do
15
15
paginated_sql = ApiPagination . paginate ( collection , per_page : per_page )
16
16
. to_sql
17
-
18
17
expect ( paginated_sql ) . to eql ( Foo . limit ( per_page ) . offset ( 0 ) . to_sql )
19
18
end
19
+ end
20
+
21
+ if ApiPagination . config . paginator == :kaminari
22
+ describe 'pagination with kaminari' do
23
+ before do
24
+ ApiPagination . config . paginator = :kaminari
25
+ end
26
+
27
+ include_examples 'produces_correct_sql'
28
+ end
29
+ end
30
+
31
+ if ApiPagination . config . paginator == :will_paginate
32
+ require 'will_paginate/active_record'
33
+
34
+ describe 'pagination with will_paginate' do
35
+ before do
36
+ ApiPagination . config . paginator = :will_paginate
37
+ end
38
+
39
+ include_examples 'produces_correct_sql'
40
+ end
20
41
end
You can’t perform that action at this time.
0 commit comments