Skip to content

Commit d3d3b36

Browse files
committed
add activerecord nulldb adapter
create model and schema for support basic activerecord functionality spec
1 parent a258d8b commit d3d3b36

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

api-pagination.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
2121
s.add_development_dependency 'railties', '>= 3.0.0'
2222
s.add_development_dependency 'actionpack', '>= 3.0.0'
2323
s.add_development_dependency 'sequel', '>= 4.9.0'
24+
s.add_development_dependency 'activerecord-nulldb-adapter', '>= 0.3.8'
2425
end

spec/active_record_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper'
2+
require 'support/active_record/foo'
3+
require 'nulldb_rspec'
4+
5+
ActiveRecord::Base.establish_connection(
6+
adapter: :nulldb,
7+
schema: 'support/active_record/schema'
8+
)
9+
10+
describe 'using kaminari with active_record' do
11+
let(:collection) { Foo.all }
12+
let(:per_page) { 5 }
13+
14+
it 'produces correct sql for first page' do
15+
paginated_sql = ApiPagination.paginate(collection, per_page: per_page)
16+
.to_sql
17+
18+
expect(paginated_sql).to eql(Foo.limit(per_page).offset(0).to_sql)
19+
end
20+
end

spec/support/active_record/foo.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require 'active_record'
2+
3+
class Foo < ActiveRecord::Base; end

spec/support/active_record/schema.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ActiveRecord::Schema.define(version: 0) do
2+
create_table "foos", :force => true do |t|
3+
t.string "foo"
4+
end
5+
end

0 commit comments

Comments
 (0)