database_cleaner 1.8.1 → 1.8.2

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: 34d0bf0798c85c01252ca0d55beebb591438e41967606e0e0197b5e1789341f5
4
- data.tar.gz: 20008c1f0341e3f10da0e9bdd083f03122e0fe0d09c12ae597190109cc5bbf3d
3
+ metadata.gz: ce938b49b786dde644fba6552ca9ed80d3c4b883b9f59d8d2c96922c3391b4ec
4
+ data.tar.gz: f6ffaab1c716a8ee0844246fbcfaebddb64dbd01a25ae1f057399121a4c75895
5
5
  SHA512:
6
- metadata.gz: f4aba72c021caf79c7a22ab362ff7c3907b711997ffebb08ac091accacca5b5c81e73485d40f0376be89f72333fc0b77b06c8ff9e426797450c1a532fe77cc77
7
- data.tar.gz: c1a015ca1eec638d714b65270e1294a1065f7a0b4d792d260a632daafb84930e14a8f149d6880a8c6c91c72359eca1c0c63be9b7c2dd16d9b4e4f04fe3ed6079
6
+ metadata.gz: 4dec342492ed7126c8f3f99ae0cac0ac60aba4559646ee7f680b5b558bc900b2242ad89729abf273389a783651233abf7c4e19a9ff4b58a1c28b3e6c26cfd166
7
+ data.tar.gz: 1fa1ff665ab2c0e7b87bbf47fda9b0e9ea0787ee5734189e7fd8834745fb14ace49f15373c6e966c65395ddd699465623aa1e155eb42398e7830b08468f9bfb5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- database_cleaner (1.8.1)
4
+ database_cleaner (1.8.2)
5
5
 
6
6
  PATH
7
7
  remote: adapters
@@ -19,10 +19,10 @@ PATH
19
19
  database_cleaner-mongo (1.8.0)
20
20
  database_cleaner (~> 1.8.0)
21
21
  mongo
22
- database_cleaner-mongo_mapper (1.8.0)
22
+ database_cleaner-mongo_mapper (1.8.1)
23
23
  database_cleaner (~> 1.8.0)
24
24
  mongo_mapper
25
- database_cleaner-mongoid (1.8.0)
25
+ database_cleaner-mongoid (1.8.1)
26
26
  database_cleaner (~> 1.8.0)
27
27
  database_cleaner-mongo (~> 1.8.0)
28
28
  mongoid
@@ -1,6 +1,15 @@
1
1
  == Development (master)
2
+
3
+ == 1.8.2 2020-02-01
4
+
2
5
  === Bug Fixes
6
+ * Fix database_cleaner-ohm autodetected adapter loading: https://github.com/DatabaseCleaner/database_cleaner/pull/619
7
+ * Fix database_cleaner-mongo_mapper autodetected adapter loading: @botandrose
8
+ * Fix database_cleaner-mongoid autodetected adapter loading: https://github.com/DatabaseCleaner/database_cleaner/pull/617
9
+ * Exclude ar_internal_metadata from truncation on Rails 5: https://github.com/DatabaseCleaner/database_cleaner/pull/588
10
+
3
11
  === Changes
12
+ * Deprecate ohm adapter: https://github.com/DatabaseCleaner/database_cleaner/pull/619
4
13
 
5
14
  == 1.8.1 2020-01-30
6
15
 
@@ -8,6 +8,8 @@ you're reading the documentation for the `master` branch.
8
8
 
9
9
  [![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner)
10
10
  [![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner)
11
+ ![Gem Version](https://badge.fury.io/rb/database_cleaner.svg)
12
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=database_cleaner&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=database_cleaner&package-manager=bundler&version-scheme=semver)
11
13
 
12
14
  Database Cleaner is a set of gems containing strategies for cleaning your database in Ruby.
13
15
 
@@ -384,4 +386,4 @@ DatabaseCleaner.url_whitelist = ['postgres://postgres@localhost', 'postgres://fo
384
386
 
385
387
  ## COPYRIGHT
386
388
 
387
- See [LICENSE] for details.
389
+ See [LICENSE](LICENSE) for details.
@@ -260,7 +260,9 @@ module DatabaseCleaner::ActiveRecord
260
260
 
261
261
  # overwritten
262
262
  def migration_storage_names
263
- [::DatabaseCleaner::ActiveRecord::Base.migration_table_name]
263
+ result = [::DatabaseCleaner::ActiveRecord::Base.migration_table_name]
264
+ result << ::ActiveRecord::Base.internal_metadata_table_name if ::ActiveRecord::VERSION::MAJOR >= 5
265
+ result
264
266
  end
265
267
 
266
268
  def cache_tables?
@@ -1,16 +1,32 @@
1
1
  require 'database_cleaner/mongo_mapper/base'
2
2
  require 'database_cleaner/generic/truncation'
3
- require 'database_cleaner/mongo/truncation_mixin'
4
3
 
5
4
  module DatabaseCleaner
6
5
  module MongoMapper
7
6
  class Truncation
8
7
  include ::DatabaseCleaner::MongoMapper::Base
9
8
  include ::DatabaseCleaner::Generic::Truncation
10
- include ::DatabaseCleaner::Mongo::TruncationMixin
11
-
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
+
12
19
  private
13
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
+
14
30
  def database
15
31
  ::MongoMapper.database
16
32
  end
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module MongoMapper
3
- VERSION = "1.8.0"
3
+ VERSION = "1.8.1"
4
4
  end
5
5
  end
@@ -0,0 +1,26 @@
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
+
@@ -1,7 +1,6 @@
1
1
  module DatabaseCleaner
2
- module Mongo2
3
- module TruncationMixin
4
-
2
+ module Mongoid
3
+ module Mongo2TruncationMixin
5
4
  def clean
6
5
  if @only
7
6
  collections.each { |c| database[c].find.delete_many if @only.include?(c) }
@@ -33,7 +32,7 @@ module DatabaseCleaner
33
32
  # name
34
33
  # end
35
34
  end
36
-
37
35
  end
38
36
  end
39
37
  end
38
+
@@ -0,0 +1,65 @@
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,8 +1,8 @@
1
1
  require 'database_cleaner/mongoid/base'
2
2
  require 'database_cleaner/generic/truncation'
3
- require 'database_cleaner/mongo/truncation_mixin'
4
- require 'database_cleaner/mongo2/truncation_mixin'
5
- require 'database_cleaner/moped/truncation_base'
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
6
  require 'mongoid/version'
7
7
 
8
8
  module DatabaseCleaner
@@ -13,7 +13,7 @@ module DatabaseCleaner
13
13
 
14
14
  if ::Mongoid::VERSION < '3'
15
15
 
16
- include ::DatabaseCleaner::Mongo::TruncationMixin
16
+ include ::DatabaseCleaner::Mongoid::Mongo1TruncationMixin
17
17
 
18
18
  private
19
19
 
@@ -23,7 +23,7 @@ module DatabaseCleaner
23
23
 
24
24
  elsif ::Mongoid::VERSION < '5'
25
25
 
26
- include ::DatabaseCleaner::Moped::TruncationBase
26
+ include ::DatabaseCleaner::Mongoid::MongoidTruncationMixin
27
27
 
28
28
  private
29
29
 
@@ -41,7 +41,7 @@ module DatabaseCleaner
41
41
 
42
42
  else
43
43
 
44
- include ::DatabaseCleaner::Mongo2::TruncationMixin
44
+ include ::DatabaseCleaner::Mongoid::Mongo2TruncationMixin
45
45
 
46
46
  end
47
47
  end
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module Mongoid
3
- VERSION = "1.8.0"
3
+ VERSION = "1.8.1"
4
4
  end
5
5
  end
@@ -2,6 +2,8 @@ require "database_cleaner/ohm/version"
2
2
  require "database_cleaner"
3
3
  require "database_cleaner/ohm/truncation"
4
4
 
5
+ DatabaseCleaner.deprecate "The Ohm adapter for DatabaseCleaner is deprecated, and will be removed in v2.0. Please use the Redis adapter instead."
6
+
5
7
  module DatabaseCleaner::Ohm
6
8
  def self.default_strategy
7
9
  :truncation
@@ -1,4 +1,9 @@
1
- require 'database_cleaner/redis/truncation'
1
+ begin # when database_cleaner-ohm is loaded as a gem
2
+ require 'database_cleaner/redis/truncation'
3
+ rescue LoadError # when database_cleaner is loaded as a gem
4
+ $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../../../../../adapters/database_cleaner-redis/lib")
5
+ require 'database_cleaner/redis/truncation'
6
+ end
2
7
 
3
8
  module DatabaseCleaner
4
9
  module Ohm
@@ -1,3 +1,3 @@
1
1
  module DatabaseCleaner
2
- VERSION = "1.8.1"
2
+ VERSION = "1.8.2"
3
3
  end
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.8.1
4
+ version: 1.8.2
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: 2020-01-31 00:00:00.000000000 Z
12
+ date: 2020-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -451,9 +451,11 @@ files:
451
451
  - adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb
452
452
  - adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb
453
453
  - adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb
454
- - adapters/database_cleaner-mongoid/lib/database_cleaner/mongo2/truncation_mixin.rb
455
454
  - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb
456
455
  - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb
456
+ - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb
457
+ - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb
458
+ - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb
457
459
  - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb
458
460
  - adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb
459
461
  - adapters/database_cleaner-moped/lib/database_cleaner-moped.rb