Skip to content

Commit e3f490f

Browse files
committed
clean up test
1 parent d3d3b36 commit e3f490f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

spec/active_record_spec.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,35 @@
77
schema: 'support/active_record/schema'
88
)
99

10-
describe 'using kaminari with active_record' do
10+
shared_examples 'produces_correct_sql' do
1111
let(:collection) { Foo.all }
1212
let(:per_page) { 5 }
1313

1414
it 'produces correct sql for first page' do
1515
paginated_sql = ApiPagination.paginate(collection, per_page: per_page)
1616
.to_sql
17-
1817
expect(paginated_sql).to eql(Foo.limit(per_page).offset(0).to_sql)
1918
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
2041
end

0 commit comments

Comments
 (0)