mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
61 lines
1.2 KiB
Ruby
61 lines
1.2 KiB
Ruby
require 'couch_potato'
|
|
require 'json/pure'
|
|
::CouchPotato::Config.database_name = 'couch_potato_test'
|
|
|
|
class CouchPotatoWidget
|
|
include CouchPotato::Persistence
|
|
|
|
property :name
|
|
view :by_name, :key => :name
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
def self.create!(attrs = {})
|
|
CouchPotato.database.save(self.new)
|
|
end
|
|
|
|
def self.count
|
|
CouchPotato.database.view(self.by_name).size
|
|
end
|
|
end
|
|
|
|
class CouchPotatoWidgetUsingDatabaseOne
|
|
include CouchPotato::Persistence
|
|
|
|
database_name = 'couch_potato_test_one'
|
|
|
|
property :name
|
|
view :by_name, :key => :name
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
def self.create!(attrs = {})
|
|
CouchPotato.database.save(self.new)
|
|
end
|
|
|
|
def self.count
|
|
CouchPotato.database.view(self.by_name).size
|
|
end
|
|
end
|
|
|
|
class CouchPotatoWidgetUsingDatabaseTwo
|
|
include CouchPotato::Persistence
|
|
|
|
database_name = 'couch_potato_test_two'
|
|
|
|
property :name
|
|
view :by_name, :key => :name
|
|
|
|
|
|
# mimic the AR interface used in example_steps
|
|
|
|
def self.create!(attrs = {})
|
|
CouchPotato.database.save(self.new)
|
|
end
|
|
|
|
def self.count
|
|
CouchPotato.database.view(self.by_name).size
|
|
end
|
|
end
|