database_cleaner 1.8.2 → 1.99.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -25
- data/History.rdoc +33 -1
- data/README.markdown +2 -2
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb +8 -0
- data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb +1 -1
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb +2 -0
- data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb +1 -1
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb +2 -0
- data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb +1 -1
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb +1 -0
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb +1 -1
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/deletion.rb +8 -0
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb +18 -6
- data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb +1 -1
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb +1 -0
- data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb +1 -1
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb +1 -0
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb +1 -1
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/deletion.rb +10 -0
- data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb +1 -1
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb +2 -0
- data/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb +1 -1
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb +1 -0
- data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb +1 -1
- data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb +1 -1
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb +1 -0
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb +7 -3
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/deletion.rb +9 -0
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb +1 -1
- data/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb +1 -1
- data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb +1 -1
- data/lib/database_cleaner/base.rb +31 -11
- data/lib/database_cleaner/configuration.rb +5 -10
- data/lib/database_cleaner/deprecation.rb +5 -0
- data/lib/database_cleaner/orm_autodetector.rb +1 -0
- data/lib/database_cleaner/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad4628851dea0ce03e2db6a48eb7da958236403160f4445655fb9ca999681bf
|
4
|
+
data.tar.gz: 1719ac34c70689ee205a6b0f148bfdd6eaf99db45731c37a495a7ad38cd6beb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25a46e41cce5d26f2b62a89cc36f3e512486851031278c113027aaed8b5d2d73072f0a6bd9e904b582c27954e5d940cf30077e0b451f5341a103ebce0876ec81
|
7
|
+
data.tar.gz: 90b1bf48990c38a8d1ecd73753926ae1287db968b834e96f09b4d119ca778f05f168e1173010506f84dd9bf6fdbf5113198bd5976f671a0c613e45c5370d2501
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,45 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
database_cleaner (1.
|
4
|
+
database_cleaner (1.99.0)
|
5
5
|
|
6
6
|
PATH
|
7
7
|
remote: adapters
|
8
8
|
specs:
|
9
|
-
database_cleaner-active_record (1.
|
9
|
+
database_cleaner-active_record (1.99.0)
|
10
10
|
activerecord
|
11
|
-
database_cleaner (~> 1.
|
12
|
-
database_cleaner-couch_potato (1.
|
11
|
+
database_cleaner (~> 1.99.0)
|
12
|
+
database_cleaner-couch_potato (1.99.0)
|
13
13
|
couch_potato
|
14
|
-
database_cleaner (~> 1.
|
15
|
-
database_cleaner-data_mapper (1.
|
16
|
-
database_cleaner (~> 1.
|
14
|
+
database_cleaner (~> 1.99.0)
|
15
|
+
database_cleaner-data_mapper (1.99.0)
|
16
|
+
database_cleaner (~> 1.99.0)
|
17
17
|
datamapper
|
18
18
|
dm-transactions
|
19
|
-
database_cleaner-mongo (1.
|
20
|
-
database_cleaner (~> 1.
|
19
|
+
database_cleaner-mongo (1.99.0)
|
20
|
+
database_cleaner (~> 1.99.0)
|
21
21
|
mongo
|
22
|
-
database_cleaner-mongo_mapper (1.
|
23
|
-
database_cleaner (~> 1.
|
22
|
+
database_cleaner-mongo_mapper (1.99.0)
|
23
|
+
database_cleaner (~> 1.99.0)
|
24
24
|
mongo_mapper
|
25
|
-
database_cleaner-mongoid (1.
|
26
|
-
database_cleaner (~> 1.
|
27
|
-
database_cleaner-mongo (~> 1.8.0)
|
25
|
+
database_cleaner-mongoid (1.99.0)
|
26
|
+
database_cleaner (~> 1.99.0)
|
28
27
|
mongoid
|
29
|
-
database_cleaner-moped (1.
|
30
|
-
database_cleaner (~> 1.
|
28
|
+
database_cleaner-moped (1.99.0)
|
29
|
+
database_cleaner (~> 1.99.0)
|
31
30
|
moped
|
32
|
-
database_cleaner-neo4j (1.
|
33
|
-
database_cleaner (~> 1.
|
31
|
+
database_cleaner-neo4j (1.99.0)
|
32
|
+
database_cleaner (~> 1.99.0)
|
34
33
|
neo4j-core
|
35
|
-
database_cleaner-ohm (1.
|
36
|
-
database_cleaner (~> 1.
|
37
|
-
database_cleaner-redis (~> 1.
|
34
|
+
database_cleaner-ohm (1.99.0)
|
35
|
+
database_cleaner (~> 1.99.0)
|
36
|
+
database_cleaner-redis (~> 1.99.0)
|
38
37
|
ohm
|
39
|
-
database_cleaner-redis (1.
|
40
|
-
database_cleaner (~> 1.
|
38
|
+
database_cleaner-redis (1.99.0)
|
39
|
+
database_cleaner (~> 1.99.0)
|
41
40
|
redis
|
42
|
-
database_cleaner-sequel (1.
|
43
|
-
database_cleaner (~> 1.
|
41
|
+
database_cleaner-sequel (1.99.0)
|
42
|
+
database_cleaner (~> 1.99.0)
|
44
43
|
sequel
|
45
44
|
|
46
45
|
GEM
|
data/History.rdoc
CHANGED
@@ -1,4 +1,36 @@
|
|
1
|
-
==
|
1
|
+
== 1.99.0 (v1-maintenance)
|
2
|
+
|
3
|
+
== Changes
|
4
|
+
* Remove unnecessary dependency on database_cleaner-mongo from database_cleaner-mongoid: @botandrose
|
5
|
+
* Enable the :cache_tables option for the mongo truncation strategy, and default to true: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
6
|
+
* Introduce deletion aliases for truncation strategies for mongo, mongoid, and redis adapters. https://github.com/DatabaseCleaner/database_cleaner/pull/654
|
7
|
+
* Add new :db orm configuration key, for consistency with #db and #db=. https://github.com/DatabaseCleaner/database_cleaner/pull/649
|
8
|
+
|
9
|
+
== Deprecations
|
10
|
+
* Deprecate all #orm= setter methods: https://github.com/DatabaseCleaner/database_cleaner/pull/643
|
11
|
+
* Deprecate non-functional :reset_ids option in ActiveRecord truncation strategy: https://github.com/DatabaseCleaner/database_cleaner/issues/559
|
12
|
+
* Deprecate mongo truncation's `:cache_tables => true` option in favor of `false`, to prep for caching removal in v2.0: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
13
|
+
* Deprecate redis truncation's #url method in favor of #db: @botandrose
|
14
|
+
* Deprecate mongo, mongoid, and redis truncation strategies in favor of deletion. https://github.com/DatabaseCleaner/database_cleaner/pull/654
|
15
|
+
* Deprecate :connection and :model configuration options in favor of :db for consistency: https://github.com/DatabaseCleaner/database_cleaner/pull/650
|
16
|
+
|
17
|
+
== Bugfixes
|
18
|
+
* Fix deprecation warning about `DatabaseCleaner.connections` to recommend a better alternative: https://github.com/DatabaseCleaner/database_cleaner/pull/656
|
19
|
+
|
20
|
+
== 1.8.5 2020-05-04
|
21
|
+
|
22
|
+
=== Bug Fixes
|
23
|
+
* Fix :mongo strategy: https://github.com/DatabaseCleaner/database_cleaner/pull/645
|
24
|
+
|
25
|
+
== 1.8.4 2020-04-02
|
26
|
+
|
27
|
+
=== Bug Fixes
|
28
|
+
* Fix false positive deprecation warnings on Windows: https://github.com/DatabaseCleaner/database_cleaner/pull/633
|
29
|
+
|
30
|
+
== 1.8.3 2020-02-18
|
31
|
+
|
32
|
+
=== Bug Fixes
|
33
|
+
* Fix performance issue of DatabaseCleaner::Base#orm_module: https://github.com/DatabaseCleaner/database_cleaner/pull/625
|
2
34
|
|
3
35
|
== 1.8.2 2020-02-01
|
4
36
|
|
data/README.markdown
CHANGED
@@ -306,10 +306,10 @@ DatabaseCleaner[:active_record].strategy = :transaction
|
|
306
306
|
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
307
307
|
|
308
308
|
# How to specify particular connections
|
309
|
-
DatabaseCleaner[:active_record, { :
|
309
|
+
DatabaseCleaner[:active_record, { :db => :two }]
|
310
310
|
|
311
311
|
# You may also pass in the model directly:
|
312
|
-
DatabaseCleaner[:active_record, { :
|
312
|
+
DatabaseCleaner[:active_record, { :db => ModelWithDifferentConnection }]
|
313
313
|
```
|
314
314
|
|
315
315
|
Usage beyond that remains the same with `DatabaseCleaner.start` calling any setup on the different configured connections, and `DatabaseCleaner.clean` executing afterwards.
|
data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_record/base'
|
2
2
|
require 'database_cleaner/active_record/base'
|
3
3
|
require 'active_record/connection_adapters/abstract_adapter'
|
4
|
+
require 'database_cleaner/deprecation'
|
4
5
|
|
5
6
|
#Load available connection adapters
|
6
7
|
%w(
|
@@ -233,6 +234,13 @@ module DatabaseCleaner::ActiveRecord
|
|
233
234
|
include ::DatabaseCleaner::ActiveRecord::Base
|
234
235
|
include ::DatabaseCleaner::Generic::Truncation
|
235
236
|
|
237
|
+
def initialize(*)
|
238
|
+
super
|
239
|
+
if !@reset_ids.nil?
|
240
|
+
DatabaseCleaner.deprecate "The `:reset_ids` option for the ActiveRecord truncation strategy has no effect, and is deprecated. It will be removed in database_cleaner 2.0 with no replacement."
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
236
244
|
def clean
|
237
245
|
connection = connection_class.connection
|
238
246
|
connection.disable_referential_integrity do
|
@@ -3,6 +3,8 @@ require "database_cleaner"
|
|
3
3
|
require "database_cleaner/couch_potato/base"
|
4
4
|
require "database_cleaner/couch_potato/truncation"
|
5
5
|
|
6
|
+
DatabaseCleaner.deprecate "Due to lack of maintenance, the Couch Potato 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!"
|
7
|
+
|
6
8
|
module DatabaseCleaner::CouchPotato
|
7
9
|
def self.default_strategy
|
8
10
|
:truncation
|
@@ -2,3 +2,5 @@ require "database_cleaner/data_mapper/version"
|
|
2
2
|
require "database_cleaner"
|
3
3
|
require "database_cleaner/data_mapper/transaction"
|
4
4
|
require "database_cleaner/data_mapper/truncation"
|
5
|
+
|
6
|
+
DatabaseCleaner.deprecate "Due to lack of maintenance, the DataMapper 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,12 +1,24 @@
|
|
1
1
|
require 'database_cleaner/mongo/base'
|
2
|
+
require 'database_cleaner/generic/base'
|
2
3
|
require 'database_cleaner/generic/truncation'
|
3
4
|
require 'database_cleaner/mongo/truncation_mixin'
|
5
|
+
require 'database_cleaner/deprecation'
|
6
|
+
|
4
7
|
module DatabaseCleaner
|
5
8
|
module Mongo
|
6
9
|
class Truncation
|
10
|
+
include ::DatabaseCleaner::Generic::Base
|
7
11
|
include ::DatabaseCleaner::Generic::Truncation
|
8
12
|
include TruncationMixin
|
9
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
|
+
|
10
22
|
private
|
11
23
|
|
12
24
|
def database
|
@@ -14,11 +26,11 @@ module DatabaseCleaner
|
|
14
26
|
end
|
15
27
|
|
16
28
|
def collections_cache
|
17
|
-
|
29
|
+
@collections_cache ||= {}
|
18
30
|
end
|
19
31
|
|
20
32
|
def mongoid_collection_names
|
21
|
-
|
33
|
+
@mongoid_collection_names ||= Hash.new{|h,k| h[k]=[]}.tap do |names|
|
22
34
|
ObjectSpace.each_object(Class) do |klass|
|
23
35
|
(names[klass.db.name] << klass.collection_name) if valid_collection_name?(klass)
|
24
36
|
end
|
@@ -26,17 +38,17 @@ module DatabaseCleaner
|
|
26
38
|
end
|
27
39
|
|
28
40
|
def not_caching(db_name, list)
|
29
|
-
|
41
|
+
@not_caching ||= {}
|
30
42
|
|
31
|
-
unless
|
32
|
-
|
43
|
+
unless @not_caching.has_key?(db_name)
|
44
|
+
@not_caching[db_name] = true
|
33
45
|
|
34
46
|
puts "Not caching collection names for db #{db_name}. Missing these from models: #{list}"
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
38
50
|
def collections
|
39
|
-
return collections_cache[database.name] if collections_cache.has_key?(database.name)
|
51
|
+
return collections_cache[database.name] if collections_cache.has_key?(database.name) && @cache_tables
|
40
52
|
db_collections = database.collections.select { |c| c.name !~ /^system\./ }
|
41
53
|
|
42
54
|
missing_collections = mongoid_collection_names[database.name] - db_collections.map(&:name)
|
@@ -2,3 +2,4 @@ require "database_cleaner/mongo_mapper/version"
|
|
2
2
|
require "database_cleaner"
|
3
3
|
require "database_cleaner/mongo_mapper/truncation"
|
4
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!"
|
@@ -2,6 +2,8 @@ require "database_cleaner/moped/version"
|
|
2
2
|
require "database_cleaner"
|
3
3
|
require "database_cleaner/moped/truncation"
|
4
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
|
+
|
5
7
|
module DatabaseCleaner::Moped
|
6
8
|
def self.default_strategy
|
7
9
|
:truncation
|
@@ -4,3 +4,4 @@ require "database_cleaner/neo4j/transaction"
|
|
4
4
|
require "database_cleaner/neo4j/truncation"
|
5
5
|
require "database_cleaner/neo4j/deletion"
|
6
6
|
|
7
|
+
DatabaseCleaner.deprecate "Due to lack of maintenance, the Neo4j 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,9 +1,10 @@
|
|
1
1
|
require 'database_cleaner/generic/base'
|
2
|
+
require 'database_cleaner/deprecation'
|
2
3
|
|
3
4
|
module DatabaseCleaner
|
4
5
|
module Redis
|
5
6
|
def self.available_strategies
|
6
|
-
%w{truncation}
|
7
|
+
%w{truncation deletion}
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.default_strategy
|
@@ -21,7 +22,10 @@ module DatabaseCleaner
|
|
21
22
|
@db ||= :default
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
+
def url
|
26
|
+
DatabaseCleaner.deprecate "The redis deletion strategy's #url method is deprecated. It will be removed in database_cleaner-redis 2.0 in favor of #db."
|
27
|
+
db
|
28
|
+
end
|
25
29
|
|
26
30
|
private
|
27
31
|
|
@@ -32,7 +36,7 @@ module DatabaseCleaner
|
|
32
36
|
elsif db.is_a?(::Redis) # pass directly the connection
|
33
37
|
db
|
34
38
|
else
|
35
|
-
::Redis.new(:url =>
|
39
|
+
::Redis.new(:url => db)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -15,7 +15,13 @@ module DatabaseCleaner
|
|
15
15
|
def initialize(desired_orm = nil, opts = {})
|
16
16
|
@orm_autodetector = ORMAutodetector.new
|
17
17
|
self.orm = desired_orm
|
18
|
-
|
18
|
+
if opts.has_key?(:model)
|
19
|
+
DatabaseCleaner.deprecate "Using the `:model` key in `DatabaseCleaner[:orm, model: ...]` is deprecated, and will be removed in database_cleaner 2.0. Please use the new `:db` key, instead, which has identical behavior: `DatabaseCleaner[:orm, db: ...]`."
|
20
|
+
end
|
21
|
+
if opts.has_key?(:connection)
|
22
|
+
DatabaseCleaner.deprecate "Using the `:connection` key in `DatabaseCleaner[:orm, connection: ...]` is deprecated, and will be removed in database_cleaner 2.0. Please use the new `:db` key, instead, which has identical behavior: `DatabaseCleaner[:orm, db: ...]`."
|
23
|
+
end
|
24
|
+
self.db = opts[:db] || opts[:connection] || opts[:model] if opts.has_key?(:db) || opts.has_key?(:connection) || opts.has_key?(:model)
|
19
25
|
self.strategy = orm_module && orm_module.default_strategy
|
20
26
|
Safeguard.new.run
|
21
27
|
end
|
@@ -30,6 +36,13 @@ module DatabaseCleaner
|
|
30
36
|
|
31
37
|
def strategy=(args)
|
32
38
|
strategy, *strategy_args = args
|
39
|
+
|
40
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller) \
|
41
|
+
&& [:redis, :mongo, :mongoid].include?(orm) \
|
42
|
+
&& strategy == :truncation
|
43
|
+
DatabaseCleaner.deprecate "The #{orm} adapter's :truncation strategy will be renamed to :deletion in database_cleaner-#{orm} 2.0. Please specify the :deletion adapter to resolve this deprecation notice."
|
44
|
+
end
|
45
|
+
|
33
46
|
@strategy = if strategy.is_a?(Symbol)
|
34
47
|
create_strategy(*args)
|
35
48
|
elsif strategy_args.empty?
|
@@ -48,6 +61,9 @@ module DatabaseCleaner
|
|
48
61
|
attr_reader :orm
|
49
62
|
|
50
63
|
def orm=(desired_orm)
|
64
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
65
|
+
DatabaseCleaner.deprecate "Calling `DatabaseCleaner[:orm].orm=` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
|
66
|
+
end
|
51
67
|
@orm = (desired_orm || :autodetect).to_sym
|
52
68
|
@orm = @orm_autodetector.orm if @orm == :autodetect
|
53
69
|
end
|
@@ -87,14 +103,14 @@ module DatabaseCleaner
|
|
87
103
|
# TODO privatize the following methods in 2.0
|
88
104
|
|
89
105
|
def strategy_db=(desired_db)
|
90
|
-
if called_externally?(caller)
|
106
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
91
107
|
DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].strategy_db=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].db=` instead."
|
92
108
|
end
|
93
109
|
set_strategy_db(strategy, desired_db)
|
94
110
|
end
|
95
111
|
|
96
112
|
def set_strategy_db(strategy, desired_db)
|
97
|
-
if called_externally?(caller)
|
113
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
98
114
|
DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].set_strategy_db=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].db=` instead."
|
99
115
|
end
|
100
116
|
if strategy.respond_to? :db=
|
@@ -105,7 +121,7 @@ module DatabaseCleaner
|
|
105
121
|
end
|
106
122
|
|
107
123
|
def create_strategy(*args)
|
108
|
-
if called_externally?(caller)
|
124
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
109
125
|
DatabaseCleaner.deprecate "Calling `DatabaseCleaner[...].create_strategy` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner[...].strategy=` instead."
|
110
126
|
end
|
111
127
|
strategy, *strategy_args = args
|
@@ -116,15 +132,23 @@ module DatabaseCleaner
|
|
116
132
|
|
117
133
|
def orm_module
|
118
134
|
return unless [:active_record, :data_mapper, :mongo, :mongoid, :mongo_mapper, :moped, :couch_potato, :sequel, :ohm, :redis, :neo4j].include?(orm)
|
135
|
+
load_adapter(orm) if !adapter_loaded?(orm)
|
136
|
+
orm_module_name = ORMAutodetector::ORMS[orm]
|
137
|
+
DatabaseCleaner.const_get(orm_module_name, false)
|
138
|
+
end
|
139
|
+
|
140
|
+
def adapter_loaded? orm
|
141
|
+
$LOADED_FEATURES.grep(%r{/lib/database_cleaner/#{orm}\.rb$}).any?
|
142
|
+
end
|
143
|
+
|
144
|
+
def load_adapter orm
|
119
145
|
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../../adapters/database_cleaner-#{orm}/lib")
|
120
146
|
require "database_cleaner/#{orm}"
|
121
|
-
orm_module_name = ORMAutodetector::ORMS[orm]
|
122
|
-
DatabaseCleaner.const_get(orm_module_name)
|
123
147
|
end
|
124
148
|
|
125
149
|
def orm_strategy(strategy)
|
126
150
|
strategy_module_name = strategy.to_s.capitalize
|
127
|
-
orm_module.const_get(strategy_module_name)
|
151
|
+
orm_module.const_get(strategy_module_name, false)
|
128
152
|
rescue NameError
|
129
153
|
if orm != :active_record
|
130
154
|
DatabaseCleaner.deprecate <<-TEXT
|
@@ -141,9 +165,5 @@ module DatabaseCleaner
|
|
141
165
|
rescue LoadError
|
142
166
|
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
143
167
|
end
|
144
|
-
|
145
|
-
def called_externally?(caller)
|
146
|
-
__FILE__ != caller.first.split(":").first
|
147
|
-
end
|
148
168
|
end
|
149
169
|
end
|
@@ -21,6 +21,7 @@ module DatabaseCleaner
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def orm=(orm)
|
24
|
+
DatabaseCleaner.deprecate "Calling `DatabaseCleaner.orm=` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
|
24
25
|
add_cleaner(:autodetect) if none?
|
25
26
|
values.each { |cleaner| cleaner.orm = orm }
|
26
27
|
remove_duplicates
|
@@ -109,8 +110,8 @@ module DatabaseCleaner
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def connections
|
112
|
-
if called_externally?(caller)
|
113
|
-
DatabaseCleaner.deprecate "Calling `DatabaseCleaner.connections` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.cleaners`, instead."
|
113
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
114
|
+
DatabaseCleaner.deprecate "Calling `DatabaseCleaner.connections` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.cleaners.values`, instead."
|
114
115
|
end
|
115
116
|
add_cleaner(:autodetect) if @cleaners.none?
|
116
117
|
@cleaners.values
|
@@ -119,23 +120,17 @@ module DatabaseCleaner
|
|
119
120
|
# TODO privatize the following methods in 2.0
|
120
121
|
|
121
122
|
def add_cleaner(orm, opts = {})
|
122
|
-
if called_externally?(caller)
|
123
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
123
124
|
DatabaseCleaner.deprecate "Calling `DatabaseCleaner.add_cleaner` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.[]`, instead."
|
124
125
|
end
|
125
126
|
@cleaners.add_cleaner(orm, opts = {})
|
126
127
|
end
|
127
128
|
|
128
129
|
def remove_duplicates
|
129
|
-
if called_externally?(caller)
|
130
|
+
if DatabaseCleaner.called_externally?(__FILE__, caller)
|
130
131
|
DatabaseCleaner.deprecate "Calling `DatabaseCleaner.remove_duplicates` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
|
131
132
|
end
|
132
133
|
@cleaners.remove_duplicates
|
133
134
|
end
|
134
|
-
|
135
|
-
private
|
136
|
-
|
137
|
-
def called_externally?(caller)
|
138
|
-
__FILE__ != caller.first.split(":").first
|
139
|
-
end
|
140
135
|
end
|
141
136
|
end
|
@@ -6,6 +6,11 @@ module DatabaseCleaner
|
|
6
6
|
end
|
7
7
|
module_function :deprecate
|
8
8
|
|
9
|
+
def called_externally?(file, caller)
|
10
|
+
file != caller.first[/^(.+\.rb):\d+/, 1]
|
11
|
+
end
|
12
|
+
module_function :called_externally?
|
13
|
+
|
9
14
|
class Deprecator
|
10
15
|
def initialize
|
11
16
|
@methods_already_warned = {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.99.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -442,6 +442,7 @@ files:
|
|
442
442
|
- adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb
|
443
443
|
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb
|
444
444
|
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb
|
445
|
+
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo/deletion.rb
|
445
446
|
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb
|
446
447
|
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb
|
447
448
|
- adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb
|
@@ -453,6 +454,7 @@ files:
|
|
453
454
|
- adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb
|
454
455
|
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb
|
455
456
|
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb
|
457
|
+
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/deletion.rb
|
456
458
|
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb
|
457
459
|
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb
|
458
460
|
- adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb
|
@@ -478,6 +480,7 @@ files:
|
|
478
480
|
- adapters/database_cleaner-redis/lib/database_cleaner-redis.rb
|
479
481
|
- adapters/database_cleaner-redis/lib/database_cleaner/redis.rb
|
480
482
|
- adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb
|
483
|
+
- adapters/database_cleaner-redis/lib/database_cleaner/redis/deletion.rb
|
481
484
|
- adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb
|
482
485
|
- adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb
|
483
486
|
- adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb
|
@@ -522,7 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
522
525
|
- !ruby/object:Gem::Version
|
523
526
|
version: '0'
|
524
527
|
requirements: []
|
525
|
-
rubygems_version: 3.0.
|
528
|
+
rubygems_version: 3.0.8
|
526
529
|
signing_key:
|
527
530
|
specification_version: 4
|
528
531
|
summary: Strategies for cleaning databases. Can be used to ensure a clean slate for
|