database_cleaner 1.99.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/database_cleaner.rb +1 -47
- metadata +12 -482
- data/CONTRIBUTE.markdown +0 -27
- data/Gemfile.lock +0 -324
- data/History.rdoc +0 -514
- data/LICENSE +0 -20
- data/README.markdown +0 -389
- data/Rakefile +0 -44
- data/TODO +0 -3
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb +0 -101
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb +0 -108
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb +0 -59
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb +0 -288
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb +0 -5
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb +0 -6
- data/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb +0 -1
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb +0 -7
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb +0 -28
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb +0 -5
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb +0 -13
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb +0 -1
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb +0 -25
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb +0 -28
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb +0 -173
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb +0 -5
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb +0 -6
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb +0 -1
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb +0 -16
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/deletion.rb +0 -8
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb +0 -74
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb +0 -26
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb +0 -5
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb +0 -11
- data/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb +0 -1
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb +0 -24
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb +0 -35
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb +0 -5
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb +0 -5
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb +0 -1
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb +0 -20
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/deletion.rb +0 -10
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb +0 -26
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb +0 -38
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb +0 -65
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb +0 -49
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb +0 -5
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb +0 -11
- data/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb +0 -1
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb +0 -39
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb +0 -9
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb +0 -44
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb +0 -5
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb +0 -12
- data/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb +0 -1
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb +0 -66
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb +0 -16
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb +0 -35
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb +0 -9
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb +0 -5
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb +0 -7
- data/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb +0 -1
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb +0 -24
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb +0 -5
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb +0 -12
- data/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb +0 -1
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb +0 -45
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/deletion.rb +0 -9
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb +0 -26
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb +0 -5
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb +0 -5
- data/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb +0 -1
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb +0 -26
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb +0 -47
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb +0 -40
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb +0 -79
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb +0 -5
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb +0 -6
- data/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb +0 -1
- data/cucumber.yml +0 -1
- data/lib/database_cleaner/base.rb +0 -169
- data/lib/database_cleaner/configuration.rb +0 -136
- data/lib/database_cleaner/cucumber.rb +0 -3
- data/lib/database_cleaner/deprecation.rb +0 -26
- data/lib/database_cleaner/generic/base.rb +0 -29
- data/lib/database_cleaner/generic/transaction.rb +0 -11
- data/lib/database_cleaner/generic/truncation.rb +0 -40
- data/lib/database_cleaner/null_strategy.rb +0 -20
- data/lib/database_cleaner/orm_autodetector.rb +0 -41
- data/lib/database_cleaner/safeguard.rb +0 -107
- data/lib/database_cleaner/spec/database_helper.rb +0 -82
- data/lib/database_cleaner/spec/shared_examples.rb +0 -15
- data/lib/database_cleaner/spec.rb +0 -2
- data/lib/database_cleaner/version.rb +0 -3
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'database_cleaner/mongo/base'
|
2
|
-
require 'database_cleaner/generic/base'
|
3
|
-
require 'database_cleaner/generic/truncation'
|
4
|
-
require 'database_cleaner/mongo/truncation_mixin'
|
5
|
-
require 'database_cleaner/deprecation'
|
6
|
-
|
7
|
-
module DatabaseCleaner
|
8
|
-
module Mongo
|
9
|
-
class Truncation
|
10
|
-
include ::DatabaseCleaner::Generic::Base
|
11
|
-
include ::DatabaseCleaner::Generic::Truncation
|
12
|
-
include TruncationMixin
|
13
|
-
include Base
|
14
|
-
|
15
|
-
def initialize(opts={})
|
16
|
-
super
|
17
|
-
if !opts.has_key?(:cache_tables) || opts[:cache_tables]
|
18
|
-
DatabaseCleaner.deprecate "The mongo adapter caches collection names between cleanings. However, this behavior can introduce test-order-dependency issues, because the collections that exist after the first test has executed are saved and used for the remainder of the suite. This means that any collection created during the subsequent tests are not cleaned! This is fixed in database_cleaner-mongo 2.0 by removing this collection caching functionality altogether. To ease the transition into this new behavior, it can be opted into by specifying the `:cache_tables` option to false: `DatabaseCleaner[:mongo].strategy = :deletion, cache_tables: false`. For more information, see https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def database
|
25
|
-
db
|
26
|
-
end
|
27
|
-
|
28
|
-
def collections_cache
|
29
|
-
@collections_cache ||= {}
|
30
|
-
end
|
31
|
-
|
32
|
-
def mongoid_collection_names
|
33
|
-
@mongoid_collection_names ||= Hash.new{|h,k| h[k]=[]}.tap do |names|
|
34
|
-
ObjectSpace.each_object(Class) do |klass|
|
35
|
-
(names[klass.db.name] << klass.collection_name) if valid_collection_name?(klass)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def not_caching(db_name, list)
|
41
|
-
@not_caching ||= {}
|
42
|
-
|
43
|
-
unless @not_caching.has_key?(db_name)
|
44
|
-
@not_caching[db_name] = true
|
45
|
-
|
46
|
-
puts "Not caching collection names for db #{db_name}. Missing these from models: #{list}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def collections
|
51
|
-
return collections_cache[database.name] if collections_cache.has_key?(database.name) && @cache_tables
|
52
|
-
db_collections = database.collections.select { |c| c.name !~ /^system\./ }
|
53
|
-
|
54
|
-
missing_collections = mongoid_collection_names[database.name] - db_collections.map(&:name)
|
55
|
-
|
56
|
-
if missing_collections.empty?
|
57
|
-
collections_cache[database.name] = db_collections
|
58
|
-
else
|
59
|
-
not_caching(database.name, missing_collections)
|
60
|
-
end
|
61
|
-
|
62
|
-
db_collections
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def valid_collection_name?(klass)
|
68
|
-
klass.ancestors.map(&:to_s).include?('Mongoid::Document') &&
|
69
|
-
!klass.embedded &&
|
70
|
-
!klass.collection_name.empty?
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module DatabaseCleaner
|
2
|
-
module Mongo
|
3
|
-
module TruncationMixin
|
4
|
-
|
5
|
-
def clean
|
6
|
-
if @only
|
7
|
-
collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
|
8
|
-
else
|
9
|
-
collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
|
10
|
-
end
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def collections
|
17
|
-
database.collections.select { |c| c.name !~ /^system\./ }
|
18
|
-
end
|
19
|
-
|
20
|
-
def truncate_method_name
|
21
|
-
# This constant only exists in the 2.x series.
|
22
|
-
defined?(::Mongo::VERSION) ? :delete_many : :remove
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require "database_cleaner/mongo"
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'database_cleaner/generic/base'
|
2
|
-
module DatabaseCleaner
|
3
|
-
module MongoMapper
|
4
|
-
def self.available_strategies
|
5
|
-
%w[truncation]
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.default_strategy
|
9
|
-
:truncation
|
10
|
-
end
|
11
|
-
|
12
|
-
module Base
|
13
|
-
include ::DatabaseCleaner::Generic::Base
|
14
|
-
|
15
|
-
def db=(desired_db)
|
16
|
-
@db = desired_db
|
17
|
-
end
|
18
|
-
|
19
|
-
def db
|
20
|
-
@db ||= :default
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'database_cleaner/mongo_mapper/base'
|
2
|
-
require 'database_cleaner/generic/truncation'
|
3
|
-
|
4
|
-
module DatabaseCleaner
|
5
|
-
module MongoMapper
|
6
|
-
class Truncation
|
7
|
-
include ::DatabaseCleaner::MongoMapper::Base
|
8
|
-
include ::DatabaseCleaner::Generic::Truncation
|
9
|
-
|
10
|
-
def clean
|
11
|
-
if @only
|
12
|
-
collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
|
13
|
-
else
|
14
|
-
collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
|
15
|
-
end
|
16
|
-
true
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def collections
|
22
|
-
database.collections.select { |c| c.name !~ /^system\./ }
|
23
|
-
end
|
24
|
-
|
25
|
-
def truncate_method_name
|
26
|
-
# This constant only exists in the 2.x series.
|
27
|
-
defined?(::Mongo::VERSION) ? :delete_many : :remove
|
28
|
-
end
|
29
|
-
|
30
|
-
def database
|
31
|
-
::MongoMapper.database
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,5 +0,0 @@
|
|
1
|
-
require "database_cleaner/mongo_mapper/version"
|
2
|
-
require "database_cleaner"
|
3
|
-
require "database_cleaner/mongo_mapper/truncation"
|
4
|
-
|
5
|
-
DatabaseCleaner.deprecate "Due to lack of maintenance, the MongoMapper adapter for DatabaseCleaner is deprecated, and will be removed in v2.0 with no replacement. Contact us if you are interested in resurrecting this adapter!"
|
@@ -1 +0,0 @@
|
|
1
|
-
require "database_cleaner/mongo_mapper"
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'database_cleaner/generic/base'
|
2
|
-
module DatabaseCleaner
|
3
|
-
module Mongoid
|
4
|
-
def self.available_strategies
|
5
|
-
%w[truncation deletion]
|
6
|
-
end
|
7
|
-
|
8
|
-
module Base
|
9
|
-
include ::DatabaseCleaner::Generic::Base
|
10
|
-
|
11
|
-
def db=(desired_db)
|
12
|
-
@db = desired_db
|
13
|
-
end
|
14
|
-
|
15
|
-
def db
|
16
|
-
@db || :default
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module DatabaseCleaner
|
2
|
-
module Mongoid
|
3
|
-
module Mongo1TruncationMixin
|
4
|
-
def clean
|
5
|
-
if @only
|
6
|
-
collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
|
7
|
-
else
|
8
|
-
collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
|
9
|
-
end
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def collections
|
16
|
-
database.collections.select { |c| c.name !~ /^system\./ }
|
17
|
-
end
|
18
|
-
|
19
|
-
def truncate_method_name
|
20
|
-
# This constant only exists in the 2.x series.
|
21
|
-
defined?(::Mongo::VERSION) ? :delete_many : :remove
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module DatabaseCleaner
|
2
|
-
module Mongoid
|
3
|
-
module Mongo2TruncationMixin
|
4
|
-
def clean
|
5
|
-
if @only
|
6
|
-
collections.each { |c| database[c].find.delete_many if @only.include?(c) }
|
7
|
-
else
|
8
|
-
collections.each { |c| database[c].find.delete_many unless @tables_to_exclude.include?(c) }
|
9
|
-
end
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def database
|
16
|
-
if @db.nil? || @db == :default
|
17
|
-
::Mongoid::Clients.default
|
18
|
-
else
|
19
|
-
::Mongoid::Clients.with_name(@db)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def collections
|
24
|
-
if db != :default
|
25
|
-
database.use(db)
|
26
|
-
end
|
27
|
-
|
28
|
-
database.collections.collect { |c| c.namespace.split('.',2)[1] }
|
29
|
-
|
30
|
-
# database['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
|
31
|
-
# _, name = collection['name'].split('.', 2)
|
32
|
-
# name
|
33
|
-
# end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'database_cleaner/generic/base'
|
2
|
-
require 'database_cleaner/generic/truncation'
|
3
|
-
|
4
|
-
module DatabaseCleaner
|
5
|
-
module Mongoid
|
6
|
-
module MongoidTruncationMixin
|
7
|
-
include ::DatabaseCleaner::Generic::Base
|
8
|
-
include ::DatabaseCleaner::Generic::Truncation
|
9
|
-
|
10
|
-
def db=(desired_db)
|
11
|
-
@db = desired_db
|
12
|
-
end
|
13
|
-
|
14
|
-
def db
|
15
|
-
@db ||= :default
|
16
|
-
end
|
17
|
-
|
18
|
-
def host_port=(desired_host)
|
19
|
-
@host = desired_host
|
20
|
-
end
|
21
|
-
|
22
|
-
def host
|
23
|
-
@host ||= '127.0.0.1:27017'
|
24
|
-
end
|
25
|
-
|
26
|
-
def db_version
|
27
|
-
@db_version ||= session.command('buildinfo' => 1)['version']
|
28
|
-
end
|
29
|
-
|
30
|
-
def clean
|
31
|
-
if @only
|
32
|
-
collections.each { |c| session[c].find.remove_all if @only.include?(c) }
|
33
|
-
else
|
34
|
-
collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) }
|
35
|
-
end
|
36
|
-
wait_for_removals_to_finish
|
37
|
-
true
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def collections
|
43
|
-
if db != :default
|
44
|
-
session.use(db)
|
45
|
-
end
|
46
|
-
|
47
|
-
if db_version.split('.').first.to_i >= 3
|
48
|
-
session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection|
|
49
|
-
collection['name']
|
50
|
-
end
|
51
|
-
else
|
52
|
-
session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
|
53
|
-
_, name = collection['name'].split('.', 2)
|
54
|
-
name
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def wait_for_removals_to_finish
|
60
|
-
session.command(getlasterror: 1)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'database_cleaner/mongoid/base'
|
2
|
-
require 'database_cleaner/generic/truncation'
|
3
|
-
require 'database_cleaner/mongoid/mongo1_truncation_mixin'
|
4
|
-
require 'database_cleaner/mongoid/mongo2_truncation_mixin'
|
5
|
-
require 'database_cleaner/mongoid/mongoid_truncation_mixin'
|
6
|
-
require 'mongoid/version'
|
7
|
-
|
8
|
-
module DatabaseCleaner
|
9
|
-
module Mongoid
|
10
|
-
class Truncation
|
11
|
-
include ::DatabaseCleaner::Mongoid::Base
|
12
|
-
include ::DatabaseCleaner::Generic::Truncation
|
13
|
-
|
14
|
-
if ::Mongoid::VERSION < '3'
|
15
|
-
|
16
|
-
include ::DatabaseCleaner::Mongoid::Mongo1TruncationMixin
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def database
|
21
|
-
::Mongoid.database
|
22
|
-
end
|
23
|
-
|
24
|
-
elsif ::Mongoid::VERSION < '5'
|
25
|
-
|
26
|
-
include ::DatabaseCleaner::Mongoid::MongoidTruncationMixin
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def session
|
31
|
-
::Mongoid::VERSION > "5.0.0" ? ::Mongoid.default_client : ::Mongoid.default_session
|
32
|
-
end
|
33
|
-
|
34
|
-
def database
|
35
|
-
if not(@db.nil? or @db == :default)
|
36
|
-
::Mongoid.databases[@db]
|
37
|
-
else
|
38
|
-
::Mongoid.database
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
else
|
43
|
-
|
44
|
-
include ::DatabaseCleaner::Mongoid::Mongo2TruncationMixin
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "database_cleaner/mongoid/version"
|
2
|
-
require "database_cleaner"
|
3
|
-
require "database_cleaner/mongoid/truncation"
|
4
|
-
require "database_cleaner/mongoid/deletion"
|
5
|
-
|
6
|
-
module DatabaseCleaner::Mongoid
|
7
|
-
def self.default_strategy
|
8
|
-
:truncation
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
require "database_cleaner/mongoid"
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'database_cleaner/generic/base'
|
2
|
-
|
3
|
-
module DatabaseCleaner
|
4
|
-
module Moped
|
5
|
-
def self.available_strategies
|
6
|
-
%w[truncation]
|
7
|
-
end
|
8
|
-
|
9
|
-
module Base
|
10
|
-
include ::DatabaseCleaner::Generic::Base
|
11
|
-
|
12
|
-
def db=(desired_db)
|
13
|
-
@db = desired_db
|
14
|
-
end
|
15
|
-
|
16
|
-
def db
|
17
|
-
@db ||= :default
|
18
|
-
end
|
19
|
-
|
20
|
-
def host_port=(desired_host)
|
21
|
-
@host = desired_host
|
22
|
-
end
|
23
|
-
|
24
|
-
def host
|
25
|
-
@host ||= '127.0.0.1:27017'
|
26
|
-
end
|
27
|
-
|
28
|
-
def db_version
|
29
|
-
@db_version ||= session.command('buildinfo' => 1)['version']
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def session
|
35
|
-
@session ||= ::Moped::Session.new([host], database: db)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'database_cleaner/moped/base'
|
2
|
-
require 'database_cleaner/generic/truncation'
|
3
|
-
|
4
|
-
module DatabaseCleaner
|
5
|
-
module Moped
|
6
|
-
module TruncationBase
|
7
|
-
include ::DatabaseCleaner::Moped::Base
|
8
|
-
include ::DatabaseCleaner::Generic::Truncation
|
9
|
-
|
10
|
-
def clean
|
11
|
-
if @only
|
12
|
-
collections.each { |c| session[c].find.remove_all if @only.include?(c) }
|
13
|
-
else
|
14
|
-
collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) }
|
15
|
-
end
|
16
|
-
wait_for_removals_to_finish
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def collections
|
23
|
-
if db != :default
|
24
|
-
session.use(db)
|
25
|
-
end
|
26
|
-
|
27
|
-
if db_version.split('.').first.to_i >= 3
|
28
|
-
session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection|
|
29
|
-
collection['name']
|
30
|
-
end
|
31
|
-
else
|
32
|
-
session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
|
33
|
-
_, name = collection['name'].split('.', 2)
|
34
|
-
name
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def wait_for_removals_to_finish
|
40
|
-
session.command(getlasterror: 1)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "database_cleaner/moped/version"
|
2
|
-
require "database_cleaner"
|
3
|
-
require "database_cleaner/moped/truncation"
|
4
|
-
|
5
|
-
DatabaseCleaner.deprecate "Due to lack of maintenance, the Moped adapter for DatabaseCleaner is deprecated, and will be removed in v2.0 with no replacement. Contact us if you are interested in resurrecting this adapter!"
|
6
|
-
|
7
|
-
module DatabaseCleaner::Moped
|
8
|
-
def self.default_strategy
|
9
|
-
:truncation
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
require "database_cleaner/moped"
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'database_cleaner/generic/base'
|
2
|
-
module DatabaseCleaner
|
3
|
-
module Neo4j
|
4
|
-
def self.available_strategies
|
5
|
-
%w[transaction truncation deletion]
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.default_strategy
|
9
|
-
:transaction
|
10
|
-
end
|
11
|
-
|
12
|
-
module Base
|
13
|
-
include ::DatabaseCleaner::Generic::Base
|
14
|
-
|
15
|
-
def db=(desired_db)
|
16
|
-
@db = desired_db == :default ? nil : desired_db
|
17
|
-
end
|
18
|
-
|
19
|
-
def db
|
20
|
-
@db ||= nil
|
21
|
-
end
|
22
|
-
|
23
|
-
def start
|
24
|
-
if db_type == :embedded_db and not session.running?
|
25
|
-
session.start
|
26
|
-
else
|
27
|
-
session
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def database
|
32
|
-
db && default_db.merge(db) || default_db
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def default_db
|
38
|
-
{:type => default_db_type, :path => default_db_path}
|
39
|
-
end
|
40
|
-
|
41
|
-
def default_db_type
|
42
|
-
:server_db
|
43
|
-
end
|
44
|
-
|
45
|
-
def default_db_path(type = default_db_type)
|
46
|
-
type == :server_db ? 'http://localhost:7475/' : './db/test'
|
47
|
-
end
|
48
|
-
|
49
|
-
def db_type
|
50
|
-
database[:type]
|
51
|
-
end
|
52
|
-
|
53
|
-
def db_path
|
54
|
-
database[:path]
|
55
|
-
end
|
56
|
-
|
57
|
-
def db_params
|
58
|
-
database.reject!{|key, value| [:type, :path].include? key }
|
59
|
-
end
|
60
|
-
|
61
|
-
def session
|
62
|
-
@session ||= ::Neo4j::Session.open(db_type, db_path, db_params)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'database_cleaner/neo4j/base'
|
2
|
-
require 'neo4j-core'
|
3
|
-
|
4
|
-
module DatabaseCleaner
|
5
|
-
module Neo4j
|
6
|
-
class Deletion
|
7
|
-
include ::DatabaseCleaner::Neo4j::Base
|
8
|
-
|
9
|
-
def clean
|
10
|
-
::Neo4j::Transaction.run do
|
11
|
-
session._query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|