Skip to content

Commit

Permalink
caches the connection class and allows DB's to be passed in as under …
Browse files Browse the repository at this point in the history
…the :db key per @kostya's patch

Previous patch that did not merge cleanly any more:
https://github.com/kostya/database_cleaner/commit/985beb3dd0a288117e1fc217c5c3011b914be224
  • Loading branch information
bmabey committed Aug 25, 2012
1 parent c06754a commit 64581a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/database_cleaner/active_record/base.rb
Expand Up @@ -45,13 +45,13 @@ def create_connection_klass


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
Expand Down
2 changes: 1 addition & 1 deletion lib/database_cleaner/base.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(desired_orm = nil,opts = {})
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

Expand Down

0 comments on commit 64581a8

Please sign in to comment.