Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit d23c17c05a8a5e310da903e49e5ea3d575ddbdd9 1 parent c209f17
@bmabey bmabey authored
View
5 README.textile
@@ -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 |
View
4 examples/features/support/env.rb
@@ -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
View
2  lib/database_cleaner/base.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.