Permalink
Browse files

changes key of passing in AR model to :model and documents it

  • Loading branch information...
1 parent c209f17 commit d23c17c05a8a5e310da903e49e5ea3d575ddbdd9 @bmabey bmabey committed Aug 25, 2012
Showing with 7 additions and 4 deletions.
  1. +4 −1 README.textile
  2. +2 −2 examples/features/support/env.rb
  3. +1 −1 lib/database_cleaner/base.rb
View
@@ -188,6 +188,9 @@ Sometimes you need to use multiple ORMs in your application. You can use Databas
#How to specify particular connections
DatabaseCleaner[:active_record,{:connection => :two}]
+
+ # You may also pass in the model directly:
+ DatabaseCleaner[:active_record,{:model => ModelWithDifferentConnection}]
</pre>
Usage beyond that remains the same with DatabaseCleaner.start calling any setup on the different configured connections, and DatabaseCleaner.clean executing afterwards.
@@ -196,7 +199,7 @@ Configuration options
|_. ORM |_. How to access |_. Notes |
-| Active Record | DatabaseCleaner[:active_record] | Connection specified as :symbol keys, loaded from config/database.yml |
+| Active Record | DatabaseCleaner[:active_record] | Connection specified as :symbol keys, loaded from config/database.yml. You may also pass in the ActiveRecord model under the @:model@ key. |
| Data Mapper | DatabaseCleaner[:data_mapper] | Connection specified as :symbol keys, loaded via Datamapper repositories |
| Mongo Mapper | DatabaseCleaner[:mongo_mapper] | Multiple connections not yet supported |
| Mongoid | DatabaseCleaner[:mongoid] | Multiple connections not yet supported |
@@ -47,8 +47,8 @@
DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_one'} ].strategy = strategy.to_sym
DatabaseCleaner[ orm_sym, {:connection => 'database_cleaner_test_two'} ].strategy = strategy.to_sym
when :active_record
- DatabaseCleaner[:active_record, {:connection => ActiveRecordWidgetUsingDatabaseOne} ].strategy = strategy.to_sym
- DatabaseCleaner[:active_record, {:connection => ActiveRecordWidgetUsingDatabaseTwo} ].strategy = strategy.to_sym
+ DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseOne} ].strategy = strategy.to_sym
+ DatabaseCleaner[:active_record, {:model => ActiveRecordWidgetUsingDatabaseTwo} ].strategy = strategy.to_sym
else
DatabaseCleaner[ orm_sym, {:connection => :one} ].strategy = strategy.to_sym
DatabaseCleaner[ orm_sym, {:connection => :two} ].strategy = strategy.to_sym
@@ -8,7 +8,7 @@ def initialize(desired_orm = nil,opts = {})
else
self.orm = desired_orm
end
- self.db = opts[:connection] || opts[:db] if opts.has_key?(:connection) || opts.has_key?(:db)
+ self.db = opts[:connection] || opts[:model] if opts.has_key?(:connection) || opts.has_key?(:model)
set_default_orm_strategy
end

0 comments on commit d23c17c

Please sign in to comment.