mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
caches the connection class and allows DB's to be passed in as under the :db key per @kostya's patch
Previous patch that did not merge cleanly any more:
985beb3dd0
This commit is contained in:
parent
c06754a540
commit
64581a8875
2 changed files with 8 additions and 8 deletions
|
@ -45,13 +45,13 @@ module DatabaseCleaner
|
|||
|
||||
|
||||
def connection_klass
|
||||
if @db == :default || (@db.nil? && connection_hash.nil?)
|
||||
::ActiveRecord::Base
|
||||
elsif connection_hash
|
||||
lookup_from_connection_pool || establish_connection
|
||||
else
|
||||
@db # allows for an actual class to be passed in
|
||||
end
|
||||
@connection_klass ||= if @db == :default || (@db.nil? && connection_hash.nil?)
|
||||
::ActiveRecord::Base
|
||||
elsif connection_hash
|
||||
lookup_from_connection_pool || establish_connection
|
||||
else
|
||||
@db # allows for an actual class to be passed in
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,7 +8,7 @@ module DatabaseCleaner
|
|||
else
|
||||
self.orm = desired_orm
|
||||
end
|
||||
self.db = opts[:connection] if opts.has_key? :connection
|
||||
self.db = opts[:connection] || opts[:db] if opts.has_key?(:connection) || opts.has_key?(:db)
|
||||
set_default_orm_strategy
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue