mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Speed up the test suite by bulk-inserting fixture data
This commit is contained in:
parent
a43335cc31
commit
734a73aae4
2 changed files with 11 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
if defined? ActiveRecord
|
||||
require 'activerecord-import'
|
||||
|
||||
class ActiveRecordModelExtensionTest < ActiveSupport::TestCase
|
||||
test 'Changing page_method_name' do
|
||||
begin
|
||||
|
@ -30,8 +32,11 @@ if defined? ActiveRecord
|
|||
class << self
|
||||
def startup
|
||||
[User, GemDefinedModel, Device].each do |m|
|
||||
1.upto(100) {|i| m.create! name: "user#{'%03d' % i}", age: (i / 10)}
|
||||
collection = 1.upto(100).map {|i| m.new(name: "user#{'%03d' % i}", age: (i / 10)) }
|
||||
|
||||
insert(collection)
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -39,6 +44,10 @@ if defined? ActiveRecord
|
|||
[User, GemDefinedModel, Device].each(&:delete_all)
|
||||
super
|
||||
end
|
||||
|
||||
def insert(collection)
|
||||
collection.first.class.import collection
|
||||
end
|
||||
end
|
||||
|
||||
[User, Admin, GemDefinedModel, Device].each do |model_class|
|
||||
|
|
|
@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
|
|||
spec.add_development_dependency 'rake', '>= 0'
|
||||
spec.add_development_dependency 'rr', '>= 0'
|
||||
spec.add_development_dependency 'capybara', '>= 1.0'
|
||||
spec.add_development_dependency 'activerecord-import'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue