database_cleaner-mongo 1.8.1 → 1.99.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/database_cleaner-mongo.gemspec +1 -1
- data/lib/database_cleaner/mongo.rb +1 -0
- data/lib/database_cleaner/mongo/base.rb +1 -1
- data/lib/database_cleaner/mongo/deletion.rb +8 -0
- data/lib/database_cleaner/mongo/truncation.rb +16 -6
- data/lib/database_cleaner/mongo/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 761dd7ff9cb6fc987a767554f6f23e169b7e8f63a96d0df4c51204513154130f
|
4
|
+
data.tar.gz: 7a644b1e2ddf48e79a96e4e16a2089e980289e537770fafc01e37469e013923e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ab3a0045fd089d70b49e85d7a2a71bba78facb077f09337f3d7bfae585d40dd42fe2eaae04c4c274ff7e481fe286482b81b6549e1395fdef69eed014029dc3
|
7
|
+
data.tar.gz: 43c252703db7acd515eb269e1ec194b5f3a56c6368930bc9733fab7a523e6e9f1710f882fa1dd27aba8ec6adb3e881661efd63a7105dfb9cc782e0697d10baca
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
database_cleaner (1.
|
4
|
+
database_cleaner (1.99.0.beta)
|
5
5
|
|
6
6
|
PATH
|
7
7
|
remote: .
|
8
8
|
specs:
|
9
|
-
database_cleaner-mongo (1.
|
10
|
-
database_cleaner (~> 1.
|
9
|
+
database_cleaner-mongo (1.99.0.beta)
|
10
|
+
database_cleaner (~> 1.99.0.beta)
|
11
11
|
mongo
|
12
12
|
|
13
13
|
GEM
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "database_cleaner", "~> 1.
|
24
|
+
spec.add_dependency "database_cleaner", "~> 1.99.0.beta"
|
25
25
|
spec.add_dependency "mongo"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.16"
|
@@ -2,6 +2,8 @@ require 'database_cleaner/mongo/base'
|
|
2
2
|
require 'database_cleaner/generic/base'
|
3
3
|
require 'database_cleaner/generic/truncation'
|
4
4
|
require 'database_cleaner/mongo/truncation_mixin'
|
5
|
+
require 'database_cleaner/deprecation'
|
6
|
+
|
5
7
|
module DatabaseCleaner
|
6
8
|
module Mongo
|
7
9
|
class Truncation
|
@@ -9,6 +11,14 @@ module DatabaseCleaner
|
|
9
11
|
include ::DatabaseCleaner::Generic::Truncation
|
10
12
|
include TruncationMixin
|
11
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
|
+
|
12
22
|
private
|
13
23
|
|
14
24
|
def database
|
@@ -16,11 +26,11 @@ module DatabaseCleaner
|
|
16
26
|
end
|
17
27
|
|
18
28
|
def collections_cache
|
19
|
-
|
29
|
+
@collections_cache ||= {}
|
20
30
|
end
|
21
31
|
|
22
32
|
def mongoid_collection_names
|
23
|
-
|
33
|
+
@mongoid_collection_names ||= Hash.new{|h,k| h[k]=[]}.tap do |names|
|
24
34
|
ObjectSpace.each_object(Class) do |klass|
|
25
35
|
(names[klass.db.name] << klass.collection_name) if valid_collection_name?(klass)
|
26
36
|
end
|
@@ -28,17 +38,17 @@ module DatabaseCleaner
|
|
28
38
|
end
|
29
39
|
|
30
40
|
def not_caching(db_name, list)
|
31
|
-
|
41
|
+
@not_caching ||= {}
|
32
42
|
|
33
|
-
unless
|
34
|
-
|
43
|
+
unless @not_caching.has_key?(db_name)
|
44
|
+
@not_caching[db_name] = true
|
35
45
|
|
36
46
|
puts "Not caching collection names for db #{db_name}. Missing these from models: #{list}"
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
40
50
|
def collections
|
41
|
-
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
|
42
52
|
db_collections = database.collections.select { |c| c.name !~ /^system\./ }
|
43
53
|
|
44
54
|
missing_collections = mongoid_collection_names[database.name] - db_collections.map(&:name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_cleaner-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.99.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernesto Tagwerker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_cleaner
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.99.0.beta
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.99.0.beta
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/database_cleaner-mongo.rb
|
103
103
|
- lib/database_cleaner/mongo.rb
|
104
104
|
- lib/database_cleaner/mongo/base.rb
|
105
|
+
- lib/database_cleaner/mongo/deletion.rb
|
105
106
|
- lib/database_cleaner/mongo/truncation.rb
|
106
107
|
- lib/database_cleaner/mongo/truncation_mixin.rb
|
107
108
|
- lib/database_cleaner/mongo/version.rb
|
@@ -120,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
123
|
requirements:
|
123
|
-
- - "
|
124
|
+
- - ">"
|
124
125
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
126
|
+
version: 1.3.1
|
126
127
|
requirements: []
|
127
128
|
rubygems_version: 3.0.8
|
128
129
|
signing_key:
|