2010-04-13 11:50:25 -04:00
|
|
|
require 'mongoid'
|
|
|
|
|
|
|
|
Mongoid.configure do |config|
|
|
|
|
name = 'database_cleaner_test'
|
|
|
|
config.master = Mongo::Connection.new.db(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#::MongoMapper.connection = Mongo::Connection.new('127.0.0.1')
|
|
|
|
#::MongoMapper.database = 'database_cleaner_test'
|
|
|
|
|
2010-06-15 10:24:50 -04:00
|
|
|
class MongoidWidget
|
2010-04-13 11:50:25 -04:00
|
|
|
include Mongoid::Document
|
|
|
|
field :id, :type => Integer
|
|
|
|
field :name
|
|
|
|
|
|
|
|
class << self
|
2010-06-15 10:24:50 -04:00
|
|
|
#mongoid doesn't seem to provide this...
|
2010-04-13 11:50:25 -04:00
|
|
|
def create!(*args)
|
|
|
|
new(*args).save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-06-15 10:24:50 -04:00
|
|
|
|
|
|
|
class MongoidWidgetUsingDatabaseOne
|
|
|
|
include Mongoid::Document
|
|
|
|
field :id, :type => Integer
|
|
|
|
field :name
|
|
|
|
|
|
|
|
class << self
|
|
|
|
#mongoid doesn't seem to provide this...
|
|
|
|
def create!(*args)
|
|
|
|
new(*args).save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MongoidWidgetUsingDatabaseTwo
|
|
|
|
include Mongoid::Document
|
|
|
|
field :id, :type => Integer
|
|
|
|
field :name
|
|
|
|
|
|
|
|
class << self
|
|
|
|
#mongoid doesn't seem to provide this...
|
|
|
|
def create!(*args)
|
|
|
|
new(*args).save!
|
|
|
|
end
|
|
|
|
end
|
2010-08-23 16:50:32 -04:00
|
|
|
end
|