Permalink
Browse files

Make clean_with work for multiple db connections

clean_with avoids using strategy= so that it doesn't actually change the
strategy. This means it was bypassing the section that set the database
to actually clean and therefore it was always cleaning the default.
  • Loading branch information...
1 parent e12f473 commit 52b6f9f710011595c55b5e1e6ad4ec074c859d5a @johnf johnf committed Mar 24, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/database_cleaner/base.rb
@@ -36,6 +36,12 @@ def create_strategy(*args)
def clean_with(*args)
strategy = create_strategy(*args)
+ if strategy.respond_to? :db=
+ strategy.db = self.db
+ elsif self.db != :default
+ raise ArgumentError, "You must provide a strategy object that supports non default databases when you specify a database"
+ end
+
strategy.clean
strategy
end

0 comments on commit 52b6f9f

Please sign in to comment.