mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
changes to models to allow Widget/AnotherWidget for multi orm testing
This commit is contained in:
parent
b90aee8457
commit
7bf3249105
4 changed files with 41 additions and 5 deletions
|
@ -6,7 +6,16 @@ ActiveRecord::Schema.define(:version => 1) do
|
||||||
create_table :widgets do |t|
|
create_table :widgets do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table :another_widgets do |t|
|
||||||
|
t.string :name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Widget < ActiveRecord::Base
|
unless defined? Widget
|
||||||
|
class Widget < ActiveRecord::Base
|
||||||
|
end
|
||||||
|
else
|
||||||
|
class AnotherWidget < ActiveRecord::Base
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'couch_potato'
|
||||||
require 'json/pure'
|
require 'json/pure'
|
||||||
::CouchPotato::Config.database_name = 'couch_potato_test'
|
::CouchPotato::Config.database_name = 'couch_potato_test'
|
||||||
|
|
||||||
class Widget
|
class CouchWidget
|
||||||
include CouchPotato::Persistence
|
include CouchPotato::Persistence
|
||||||
|
|
||||||
property :name
|
property :name
|
||||||
|
@ -19,3 +19,11 @@ class Widget
|
||||||
CouchPotato.database.view(::Widget.by_name).size
|
CouchPotato.database.view(::Widget.by_name).size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless defined? Widget
|
||||||
|
class Widget < CouchWidget
|
||||||
|
end
|
||||||
|
else
|
||||||
|
class AnotherWidget < CouchWidget
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -7,10 +7,21 @@ require "dm-aggregates"
|
||||||
|
|
||||||
DataMapper.setup(:default, "sqlite3::memory:")
|
DataMapper.setup(:default, "sqlite3::memory:")
|
||||||
|
|
||||||
class Widget
|
class MapperWidget
|
||||||
include DataMapper::Resource
|
include DataMapper::Resource
|
||||||
property :id, Serial
|
property :id, Serial
|
||||||
property :name, String
|
property :name, String
|
||||||
end
|
end
|
||||||
|
|
||||||
Widget.auto_migrate!
|
|
||||||
|
unless defined? Widget
|
||||||
|
class Widget < MapperWidget
|
||||||
|
end
|
||||||
|
|
||||||
|
Widget.auto_migrate!
|
||||||
|
else
|
||||||
|
class AnotherWidget < MapperWidget
|
||||||
|
end
|
||||||
|
|
||||||
|
AnotherWidget.auto_migrate!
|
||||||
|
end
|
|
@ -3,7 +3,7 @@ require 'mongo_mapper'
|
||||||
::MongoMapper.connection = Mongo::Connection.new('127.0.0.1')
|
::MongoMapper.connection = Mongo::Connection.new('127.0.0.1')
|
||||||
::MongoMapper.database = 'database_cleaner_test'
|
::MongoMapper.database = 'database_cleaner_test'
|
||||||
|
|
||||||
class Widget
|
class MongoWidget
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
key :id, Integer
|
key :id, Integer
|
||||||
key :name, String
|
key :name, String
|
||||||
|
@ -15,3 +15,11 @@ class Widget
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless defined? Widget
|
||||||
|
class Widget < MongoWidget
|
||||||
|
end
|
||||||
|
else
|
||||||
|
class AnotherWidget < MongoWidget
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue