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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94d45049ce71aa4bce36362e629496eea3689eb08c6e99e6a042e721a3f1e3d0
4
- data.tar.gz: a7b4ceef2a19913d7e3cb9128256cfef2fa4cd7cbedc034dd19fc19c277cc1b2
3
+ metadata.gz: 761dd7ff9cb6fc987a767554f6f23e169b7e8f63a96d0df4c51204513154130f
4
+ data.tar.gz: 7a644b1e2ddf48e79a96e4e16a2089e980289e537770fafc01e37469e013923e
5
5
  SHA512:
6
- metadata.gz: be6ed0e9839ba3d9ff70f1641ded5f9f61015af9d5cf40d0437eef03b9db34411d13c005f6bbc64e3b5b00fe43031ff8929746faa987c7b40ff24386729c26f8
7
- data.tar.gz: 14a7cfef45c78918e3eb245d8c86c79413b1b7a042d50aacd167d661a02cc1b3fb112ac9930ecfa8045858aa6e97f83628481beb1a004d93835af2c5c37c9c70
6
+ metadata.gz: 38ab3a0045fd089d70b49e85d7a2a71bba78facb077f09337f3d7bfae585d40dd42fe2eaae04c4c274ff7e481fe286482b81b6549e1395fdef69eed014029dc3
7
+ data.tar.gz: 43c252703db7acd515eb269e1ec194b5f3a56c6368930bc9733fab7a523e6e9f1710f882fa1dd27aba8ec6adb3e881661efd63a7105dfb9cc782e0697d10baca
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- database_cleaner (1.8.5)
4
+ database_cleaner (1.99.0.beta)
5
5
 
6
6
  PATH
7
7
  remote: .
8
8
  specs:
9
- database_cleaner-mongo (1.8.1)
10
- database_cleaner (~> 1.8.0)
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.8.0"
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"
@@ -1,6 +1,7 @@
1
1
  require 'database_cleaner/mongo/version'
2
2
  require 'database_cleaner'
3
3
  require 'database_cleaner/mongo/truncation'
4
+ require 'database_cleaner/mongo/deletion'
4
5
 
5
6
  module DatabaseCleaner::Mongo
6
7
  def self.default_strategy
@@ -1,7 +1,7 @@
1
1
  module DatabaseCleaner
2
2
  module Mongo
3
3
  def self.available_strategies
4
- %w[truncation]
4
+ %w[truncation deletion]
5
5
  end
6
6
  module Base
7
7
  def db=(desired_db)
@@ -0,0 +1,8 @@
1
+ require 'database_cleaner/mongo/truncation'
2
+
3
+ module DatabaseCleaner
4
+ module Mongo
5
+ class Deletion < Truncation
6
+ end
7
+ end
8
+ end
@@ -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
- @@collections_cache ||= {}
29
+ @collections_cache ||= {}
20
30
  end
21
31
 
22
32
  def mongoid_collection_names
23
- @@mongoid_collection_names ||= Hash.new{|h,k| h[k]=[]}.tap do |names|
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
- @@not_caching ||= {}
41
+ @not_caching ||= {}
32
42
 
33
- unless @@not_caching.has_key?(db_name)
34
- @@not_caching[db_name] = true
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)
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module Mongo
3
- VERSION = "1.8.1"
3
+ VERSION = "1.99.0.beta"
4
4
  end
5
5
  end
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.8.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-04 00:00:00.000000000 Z
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.8.0
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.8.0
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: '0'
126
+ version: 1.3.1
126
127
  requirements: []
127
128
  rubygems_version: 3.0.8
128
129
  signing_key: