Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
a04a6a543f |
22 changed files with 50 additions and 162 deletions
2
Rakefile
2
Rakefile
|
@ -36,7 +36,7 @@ namespace :display do
|
||||||
end
|
end
|
||||||
task :default => ["display:notice"]
|
task :default => ["display:notice"]
|
||||||
|
|
||||||
ADAPTERS = %w(mysql mysql2 jdbcmysql postgresql sqlite3 seamless_database_pool mysqlspatial mysql2spatial spatialite postgis)
|
ADAPTERS = %w(mysql mysql2 jdbcmysql postgresql sqlite3 seamless_database_pool)
|
||||||
ADAPTERS.each do |adapter|
|
ADAPTERS.each do |adapter|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
desc "Runs #{adapter} database tests."
|
desc "Runs #{adapter} database tests."
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require "active_record/connection_adapters/mysql2_adapter"
|
require "active_record/connection_adapters/mysql2_adapter"
|
||||||
require "activerecord-import/adapters/mysql2_adapter"
|
require "activerecord-import/adapters/mysql_adapter"
|
||||||
|
|
||||||
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
||||||
include ActiveRecord::Import::Mysql2Adapter
|
include ActiveRecord::Import::MysqlAdapter
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "active_record/connection_adapters/sqlite3_adapter"
|
require "active_record/connection_adapters/sqlite3_adapter"
|
||||||
require "activerecord-import/adapters/sqlite3_adapter"
|
require "activerecord-import/adapters/sqlite3_adapter"
|
||||||
|
|
||||||
class ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
class ActiveRecord::ConnectionAdapters::Sqlite3Adapter
|
||||||
include ActiveRecord::Import::SQLite3Adapter
|
include ActiveRecord::Import::Sqlite3Adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ module ActiveRecord::Import::AbstractAdapter
|
||||||
# elements that are in position >= 1 will be appended to the final SQL.
|
# elements that are in position >= 1 will be appended to the final SQL.
|
||||||
def insert_many( sql, values, *args ) # :nodoc:
|
def insert_many( sql, values, *args ) # :nodoc:
|
||||||
# the number of inserts default
|
# the number of inserts default
|
||||||
number_of_inserts, last_inserted_id = 0, nil
|
number_of_inserts = 0
|
||||||
|
|
||||||
base_sql,post_sql = if sql.is_a?( String )
|
base_sql,post_sql = if sql.is_a?( String )
|
||||||
[ sql, '' ]
|
[ sql, '' ]
|
||||||
|
@ -59,17 +59,17 @@ module ActiveRecord::Import::AbstractAdapter
|
||||||
if NO_MAX_PACKET == max or total_bytes < max
|
if NO_MAX_PACKET == max or total_bytes < max
|
||||||
number_of_inserts += 1
|
number_of_inserts += 1
|
||||||
sql2insert = base_sql + values.join( ',' ) + post_sql
|
sql2insert = base_sql + values.join( ',' ) + post_sql
|
||||||
last_inserted_id = insert( sql2insert, *args )
|
insert( sql2insert, *args )
|
||||||
else
|
else
|
||||||
value_sets = self.class.get_insert_value_sets( values, sql_size, max )
|
value_sets = self.class.get_insert_value_sets( values, sql_size, max )
|
||||||
value_sets.each do |values|
|
value_sets.each do |values|
|
||||||
number_of_inserts += 1
|
number_of_inserts += 1
|
||||||
sql2insert = base_sql + values.join( ',' ) + post_sql
|
sql2insert = base_sql + values.join( ',' ) + post_sql
|
||||||
last_inserted_id = insert( sql2insert, *args )
|
insert( sql2insert, *args )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[number_of_inserts, last_inserted_id]
|
number_of_inserts
|
||||||
end
|
end
|
||||||
|
|
||||||
def pre_sql_statements(options)
|
def pre_sql_statements(options)
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
require File.dirname(__FILE__) + "/mysql_adapter"
|
|
||||||
|
|
||||||
module ActiveRecord::Import::Mysql2Adapter
|
|
||||||
include ActiveRecord::Import::MysqlAdapter
|
|
||||||
end
|
|
|
@ -1,4 +1,4 @@
|
||||||
module ActiveRecord::Import::SQLite3Adapter
|
module ActiveRecord::Import::Sqlite3Adapter
|
||||||
def next_value_for_sequence(sequence_name)
|
def next_value_for_sequence(sequence_name)
|
||||||
%{nextval('#{sequence_name}')}
|
%{nextval('#{sequence_name}')}
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,20 +5,10 @@ require "active_record/version"
|
||||||
module ActiveRecord::Import
|
module ActiveRecord::Import
|
||||||
AdapterPath = File.join File.expand_path(File.dirname(__FILE__)), "/active_record/adapters"
|
AdapterPath = File.join File.expand_path(File.dirname(__FILE__)), "/active_record/adapters"
|
||||||
|
|
||||||
def self.base_adapter(adapter)
|
|
||||||
case adapter
|
|
||||||
when 'mysqlspatial' then 'mysql'
|
|
||||||
when 'mysql2spatial' then 'mysql2'
|
|
||||||
when 'spatialite' then 'sqlite3'
|
|
||||||
when 'postgis' then 'postgresql'
|
|
||||||
else adapter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Loads the import functionality for a specific database adapter
|
# Loads the import functionality for a specific database adapter
|
||||||
def self.require_adapter(adapter)
|
def self.require_adapter(adapter)
|
||||||
require File.join(AdapterPath,"/abstract_adapter")
|
require File.join(AdapterPath,"/abstract_adapter")
|
||||||
require File.join(AdapterPath,"/#{base_adapter(adapter)}_adapter")
|
require File.join(AdapterPath,"/#{adapter}_adapter")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads the import functionality for the passed in ActiveRecord connection
|
# Loads the import functionality for the passed in ActiveRecord connection
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "ostruct"
|
||||||
module ActiveRecord::Import::ConnectionAdapters ; end
|
module ActiveRecord::Import::ConnectionAdapters ; end
|
||||||
|
|
||||||
module ActiveRecord::Import #:nodoc:
|
module ActiveRecord::Import #:nodoc:
|
||||||
class Result < Struct.new(:failed_instances, :num_inserts, :last_inserted_id)
|
class Result < Struct.new(:failed_instances, :num_inserts)
|
||||||
end
|
end
|
||||||
|
|
||||||
module ImportSupport #:nodoc:
|
module ImportSupport #:nodoc:
|
||||||
|
@ -137,8 +137,8 @@ class ActiveRecord::Base
|
||||||
#
|
#
|
||||||
# # Example synchronizing unsaved/new instances in memory by using a uniqued imported field
|
# # Example synchronizing unsaved/new instances in memory by using a uniqued imported field
|
||||||
# posts = [BlogPost.new(:title => "Foo"), BlogPost.new(:title => "Bar")]
|
# posts = [BlogPost.new(:title => "Foo"), BlogPost.new(:title => "Bar")]
|
||||||
# BlogPost.import posts, :synchronize => posts, :synchronize_keys => [:title]
|
# BlogPost.import posts, :synchronize => posts
|
||||||
# puts posts.first.persisted? # => true
|
# puts posts.first.new_record? # => false
|
||||||
#
|
#
|
||||||
# == On Duplicate Key Update (MySQL only)
|
# == On Duplicate Key Update (MySQL only)
|
||||||
#
|
#
|
||||||
|
@ -162,10 +162,9 @@ class ActiveRecord::Base
|
||||||
# BlogPost.import columns, attributes, :on_duplicate_key_update=>{ :title => :title }
|
# BlogPost.import columns, attributes, :on_duplicate_key_update=>{ :title => :title }
|
||||||
#
|
#
|
||||||
# = Returns
|
# = Returns
|
||||||
# This returns an object which responds to +failed_instances+, +num_inserts+, +last_inserted_id+.
|
# This returns an object which responds to +failed_instances+ and +num_inserts+.
|
||||||
# * failed_instances - an array of objects that fails validation and were not committed to the database. An empty array if no validation is performed.
|
# * failed_instances - an array of objects that fails validation and were not committed to the database. An empty array if no validation is performed.
|
||||||
# * num_inserts - the number of insert statements it took to import the data.
|
# * num_inserts - the number of insert statements it took to import the data
|
||||||
# * last_inserted_id - the last inserted id. Should be the id of the latest inserted row.
|
|
||||||
def import( *args )
|
def import( *args )
|
||||||
options = { :validate=>true, :timestamps=>true }
|
options = { :validate=>true, :timestamps=>true }
|
||||||
options.merge!( args.pop ) if args.last.is_a? Hash
|
options.merge!( args.pop ) if args.last.is_a? Hash
|
||||||
|
@ -192,7 +191,7 @@ class ActiveRecord::Base
|
||||||
end
|
end
|
||||||
# supports empty array
|
# supports empty array
|
||||||
elsif args.last.is_a?( Array ) and args.last.empty?
|
elsif args.last.is_a?( Array ) and args.last.empty?
|
||||||
return ActiveRecord::Import::Result.new([], 0, nil) if args.last.empty?
|
return ActiveRecord::Import::Result.new([], 0) if args.last.empty?
|
||||||
# supports 2-element array and array
|
# supports 2-element array and array
|
||||||
elsif args.size == 2 and args.first.is_a?( Array ) and args.last.is_a?( Array )
|
elsif args.size == 2 and args.first.is_a?( Array ) and args.last.is_a?( Array )
|
||||||
column_names, array_of_attributes = args
|
column_names, array_of_attributes = args
|
||||||
|
@ -219,8 +218,8 @@ class ActiveRecord::Base
|
||||||
return_obj = if is_validating
|
return_obj = if is_validating
|
||||||
import_with_validations( column_names, array_of_attributes, options )
|
import_with_validations( column_names, array_of_attributes, options )
|
||||||
else
|
else
|
||||||
[num_inserts, last_inserted_id] = import_without_validations_or_callbacks( column_names, array_of_attributes, options )
|
num_inserts = import_without_validations_or_callbacks( column_names, array_of_attributes, options )
|
||||||
ActiveRecord::Import::Result.new([], num_inserts, last_inserted_id)
|
ActiveRecord::Import::Result.new([], num_inserts)
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:synchronize]
|
if options[:synchronize]
|
||||||
|
@ -262,12 +261,12 @@ class ActiveRecord::Base
|
||||||
end
|
end
|
||||||
array_of_attributes.compact!
|
array_of_attributes.compact!
|
||||||
|
|
||||||
num_inserts, last_inserted_id = if array_of_attributes.empty? || options[:all_or_none] && failed_instances.any?
|
num_inserts = if array_of_attributes.empty? || options[:all_or_none] && failed_instances.any?
|
||||||
[0, nil]
|
0
|
||||||
else
|
else
|
||||||
import_without_validations_or_callbacks( column_names, array_of_attributes, options )
|
import_without_validations_or_callbacks( column_names, array_of_attributes, options )
|
||||||
end
|
end
|
||||||
ActiveRecord::Import::Result.new(failed_instances, num_inserts, last_inserted_id)
|
ActiveRecord::Import::Result.new(failed_instances, num_inserts)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Imports the passed in +column_names+ and +array_of_attributes+
|
# Imports the passed in +column_names+ and +array_of_attributes+
|
||||||
|
@ -277,14 +276,6 @@ class ActiveRecord::Base
|
||||||
# information on +column_names+, +array_of_attributes_ and
|
# information on +column_names+, +array_of_attributes_ and
|
||||||
# +options+.
|
# +options+.
|
||||||
def import_without_validations_or_callbacks( column_names, array_of_attributes, options={} )
|
def import_without_validations_or_callbacks( column_names, array_of_attributes, options={} )
|
||||||
number_inserted, last_inserted_id = 0, nil
|
|
||||||
scope_columns, scope_values = scope_attributes.to_a.transpose
|
|
||||||
|
|
||||||
unless scope_columns.blank?
|
|
||||||
column_names.concat scope_columns
|
|
||||||
array_of_attributes.each { |a| a.concat scope_values }
|
|
||||||
end
|
|
||||||
|
|
||||||
columns = column_names.each_with_index.map do |name, i|
|
columns = column_names.each_with_index.map do |name, i|
|
||||||
column = columns_hash[name.to_s]
|
column = columns_hash[name.to_s]
|
||||||
|
|
||||||
|
@ -307,11 +298,11 @@ class ActiveRecord::Base
|
||||||
post_sql_statements = connection.post_sql_statements( quoted_table_name, options )
|
post_sql_statements = connection.post_sql_statements( quoted_table_name, options )
|
||||||
|
|
||||||
# perform the inserts
|
# perform the inserts
|
||||||
number_inserted, last_inserted_id = connection.insert_many( [ insert_sql, post_sql_statements ].flatten,
|
number_inserted = connection.insert_many( [ insert_sql, post_sql_statements ].flatten,
|
||||||
values_sql,
|
values_sql,
|
||||||
"#{self.class.name} Create Many Without Validations Or Callbacks" )
|
"#{self.class.name} Create Many Without Validations Or Callbacks" )
|
||||||
end
|
end
|
||||||
[number_inserted, last_inserted_id]
|
number_inserted
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -319,22 +310,14 @@ class ActiveRecord::Base
|
||||||
# Returns SQL the VALUES for an INSERT statement given the passed in +columns+
|
# Returns SQL the VALUES for an INSERT statement given the passed in +columns+
|
||||||
# and +array_of_attributes+.
|
# and +array_of_attributes+.
|
||||||
def values_sql_for_columns_and_attributes(columns, array_of_attributes) # :nodoc:
|
def values_sql_for_columns_and_attributes(columns, array_of_attributes) # :nodoc:
|
||||||
# connection gets called a *lot* in this high intensity loop.
|
|
||||||
# Reuse the same one w/in the loop, otherwise it would keep being re-retreived (= lots of time for large imports)
|
|
||||||
connection_memo = connection
|
|
||||||
array_of_attributes.map do |arr|
|
array_of_attributes.map do |arr|
|
||||||
my_values = arr.each_with_index.map do |val,j|
|
my_values = arr.each_with_index.map do |val,j|
|
||||||
column = columns[j]
|
column = columns[j]
|
||||||
|
|
||||||
# be sure to query sequence_name *last*, only if cheaper tests fail, because it's costly
|
if val.nil? && !sequence_name.blank? && column.name == primary_key
|
||||||
if val.nil? && column.name == primary_key && !sequence_name.blank?
|
connection.next_value_for_sequence(sequence_name)
|
||||||
connection_memo.next_value_for_sequence(sequence_name)
|
|
||||||
else
|
else
|
||||||
if serialized_attributes.include?(column.name)
|
connection.quote(column.type_cast(val), column)
|
||||||
connection_memo.quote(serialized_attributes[column.name].dump(val), column)
|
|
||||||
else
|
|
||||||
connection_memo.quote(val, column)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"(#{my_values.join(',')})"
|
"(#{my_values.join(',')})"
|
||||||
|
|
|
@ -43,10 +43,6 @@ module ActiveRecord # :nodoc:
|
||||||
instance.clear_aggregation_cache
|
instance.clear_aggregation_cache
|
||||||
instance.clear_association_cache
|
instance.clear_association_cache
|
||||||
instance.instance_variable_set '@attributes', matched_instance.attributes
|
instance.instance_variable_set '@attributes', matched_instance.attributes
|
||||||
# Since the instance now accurately reflects the record in
|
|
||||||
# the database, ensure that instance.persisted? is true.
|
|
||||||
instance.instance_variable_set '@new_record', false
|
|
||||||
instance.instance_variable_set '@destroyed', false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,13 +50,3 @@ describe "ActiveRecord::ConnectionAdapter::AbstractAdapter" do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "ActiveRecord::Import DB-specific adapter class" do
|
|
||||||
context "when ActiveRecord::Import is in use" do
|
|
||||||
it "should appear in the AR connection adapter class's ancestors" do
|
|
||||||
connection = ActiveRecord::Base.connection
|
|
||||||
import_class_name = 'ActiveRecord::Import::' + connection.class.name.demodulize
|
|
||||||
assert_includes connection.class.ancestors, import_class_name.constantize
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
ENV["ARE_DB"] = "mysql2spatial"
|
|
|
@ -1 +0,0 @@
|
||||||
ENV["ARE_DB"] = "mysqlspatial"
|
|
|
@ -1 +0,0 @@
|
||||||
ENV["ARE_DB"] = "postgis"
|
|
|
@ -1 +0,0 @@
|
||||||
ENV["ARE_DB"] = "spatialite"
|
|
|
@ -13,12 +13,6 @@ mysql2:
|
||||||
<<: *common
|
<<: *common
|
||||||
adapter: mysql2
|
adapter: mysql2
|
||||||
|
|
||||||
mysqlspatial:
|
|
||||||
<<: *mysql
|
|
||||||
|
|
||||||
mysqlspatial2:
|
|
||||||
<<: *mysql2
|
|
||||||
|
|
||||||
seamless_database_pool:
|
seamless_database_pool:
|
||||||
<<: *common
|
<<: *common
|
||||||
adapter: seamless_database_pool
|
adapter: seamless_database_pool
|
||||||
|
@ -32,9 +26,6 @@ postgresql:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
min_messages: warning
|
min_messages: warning
|
||||||
|
|
||||||
postgis:
|
|
||||||
<<: *postgresql
|
|
||||||
|
|
||||||
oracle:
|
oracle:
|
||||||
<<: *common
|
<<: *common
|
||||||
adapter: oracle
|
adapter: oracle
|
||||||
|
@ -47,6 +38,3 @@ sqlite:
|
||||||
sqlite3:
|
sqlite3:
|
||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
database: test.db
|
database: test.db
|
||||||
|
|
||||||
spatialite:
|
|
||||||
<<: *sqlite3
|
|
||||||
|
|
|
@ -134,18 +134,8 @@ describe "#import" do
|
||||||
let(:new_topics) { Build(3, :topics) }
|
let(:new_topics) { Build(3, :topics) }
|
||||||
|
|
||||||
it "reloads data for existing in-memory instances" do
|
it "reloads data for existing in-memory instances" do
|
||||||
Topic.import(new_topics, :synchronize => new_topics, :synchronize_keys => [:title] )
|
Topic.import(new_topics, :synchronize => new_topics, :synchronize_key => [:title] )
|
||||||
assert new_topics.all?(&:persisted?), "Records should have been reloaded"
|
assert new_topics.all?(&:new_record?), "Records should have been reloaded"
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "synchronizing on destroyed records with explicit conditions" do
|
|
||||||
let(:new_topics) { Generate(3, :topics) }
|
|
||||||
|
|
||||||
it "reloads data for existing in-memory instances" do
|
|
||||||
new_topics.each &:destroy
|
|
||||||
Topic.import(new_topics, :synchronize => new_topics, :synchronize_keys => [:title] )
|
|
||||||
assert new_topics.all?(&:persisted?), "Records should have been reloaded"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -303,18 +293,4 @@ describe "#import" do
|
||||||
assert_equal "2010/05/14".to_date, Topic.last.last_read.to_date
|
assert_equal "2010/05/14".to_date, Topic.last.last_read.to_date
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "importing through an association scope" do
|
|
||||||
[ true, false ].each do |b|
|
|
||||||
context "when validation is " + (b ? "enabled" : "disabled") do
|
|
||||||
it "should automatically set the foreign key column" do
|
|
||||||
books = [[ "David Chelimsky", "The RSpec Book" ], [ "Chad Fowler", "Rails Recipes" ]]
|
|
||||||
topic = Factory.create :topic
|
|
||||||
topic.books.import [ :author_name, :title ], books, :validate => b
|
|
||||||
assert_equal 2, topic.books.count
|
|
||||||
assert topic.books.all? { |b| b.topic_id == topic.id }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,6 +0,0 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/mysql/assertions')
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/mysql/import_examples')
|
|
||||||
|
|
||||||
should_support_mysql_import_functionality
|
|
|
@ -1,6 +0,0 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/mysql/assertions')
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/mysql/import_examples')
|
|
||||||
|
|
||||||
should_support_mysql_import_functionality
|
|
|
@ -1,4 +0,0 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/postgresql/import_examples')
|
|
||||||
|
|
||||||
should_support_postgresql_import_functionality
|
|
|
@ -1,4 +1,20 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../support/postgresql/import_examples')
|
|
||||||
|
|
||||||
should_support_postgresql_import_functionality
|
describe "#supports_imports?" do
|
||||||
|
it "should support import" do
|
||||||
|
assert ActiveRecord::Base.supports_import?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#import" do
|
||||||
|
it "should import with a single insert" do
|
||||||
|
# see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics
|
||||||
|
assert_difference "Topic.count", +10 do
|
||||||
|
result = Topic.import Build(3, :topics)
|
||||||
|
assert_equal 1, result.num_inserts
|
||||||
|
|
||||||
|
result = Topic.import Build(7, :topics)
|
||||||
|
assert_equal 1, result.num_inserts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# encoding: UTF-8
|
|
||||||
def should_support_postgresql_import_functionality
|
|
||||||
describe "#supports_imports?" do
|
|
||||||
it "should support import" do
|
|
||||||
assert ActiveRecord::Base.supports_import?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#import" do
|
|
||||||
it "should import with a single insert" do
|
|
||||||
# see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics
|
|
||||||
assert_difference "Topic.count", +10 do
|
|
||||||
result = Topic.import Build(3, :topics)
|
|
||||||
assert_equal 1, result.num_inserts
|
|
||||||
|
|
||||||
result = Topic.import Build(7, :topics)
|
|
||||||
assert_equal 1, result.num_inserts
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -44,8 +44,3 @@ adapter_schema = test_dir.join("schema/#{adapter}_schema.rb")
|
||||||
require adapter_schema if File.exists?(adapter_schema)
|
require adapter_schema if File.exists?(adapter_schema)
|
||||||
|
|
||||||
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|
||||||
|
|
||||||
# Prevent this deprecation warning from breaking the tests.
|
|
||||||
module Rake::DeprecatedObjectDSL
|
|
||||||
remove_method :import
|
|
||||||
end
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue