database_cleaner/examples/lib/couchpotato_models.rb

62 lines
1.2 KiB
Ruby
Raw Normal View History

require 'couch_potato'
require 'json/pure' unless defined? ::JSON
::CouchPotato::Config.database_name = 'couch_potato_test'
class CouchPotatoWidget
include CouchPotato::Persistence
2010-05-30 23:12:58 -04:00
property :name
view :by_name, :key => :name
2010-05-30 23:12:58 -04:00
# mimic the AR interface used in example_steps
def self.create!(attrs = {})
CouchPotato.database.save(self.new)
end
2010-05-30 23:12:58 -04:00
def self.count
CouchPotato.database.view(self.by_name).size
end
end
class CouchPotatoWidgetUsingDatabaseOne
include CouchPotato::Persistence
2010-05-30 23:12:58 -04:00
database_name = 'couch_potato_test_one'
2010-05-30 23:12:58 -04:00
property :name
view :by_name, :key => :name
2010-05-30 23:12:58 -04:00
# mimic the AR interface used in example_steps
def self.create!(attrs = {})
CouchPotato.database.save(self.new)
end
2010-05-30 23:12:58 -04:00
def self.count
CouchPotato.database.view(self.by_name).size
end
end
class CouchPotatoWidgetUsingDatabaseTwo
include CouchPotato::Persistence
database_name = 'couch_potato_test_two'
2010-05-30 23:12:58 -04:00
property :name
view :by_name, :key => :name
2010-05-30 23:12:58 -04:00
# mimic the AR interface used in example_steps
def self.create!(attrs = {})
CouchPotato.database.save(self.new)
end
2010-05-30 23:12:58 -04:00
def self.count
CouchPotato.database.view(self.by_name).size
end
end