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:
Ben Mabey 2012-08-25 11:46:01 -06:00
parent c06754a540
commit 64581a8875
2 changed files with 8 additions and 8 deletions

View file

@ -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

View file

@ -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