database_cleaner-active_record 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f4e22827466f77ef287a8cfa7cf75078940f69f4e3b222676d7cb30d74edb74
4
- data.tar.gz: 942936724f8ef0e4a0107044aef35b203e6e8d23c1a6d241d452342eb1d8ae17
3
+ metadata.gz: 997c59d22ce3ef9178c0b69c3d30b98d2e1126ddf099b5630bf0fbc272c76280
4
+ data.tar.gz: c8fc2baa15ceb2d6efb1b6b3a0890868dad0b5b51c78929b39564cc6e2be0c0f
5
5
  SHA512:
6
- metadata.gz: 8116e18c0f97636ab92457c6025ef7978547aba2553c747e8120b7ac528fe583f6f1cc76cbc78385c2a26fa6a6a348d37c95c5440186404259a4d50b39200b9d
7
- data.tar.gz: e847363c1be911931358c9b1cb3f09717e302b2e89aa609ce366baa1ec6664fbf3935b4c52b6785cfac25f36794992a118edc9846774a485e26fa7aeaa27896e
6
+ metadata.gz: 6ddd99b203a2a712c8adbf01de42dbc751894ffe52f61cc540ebc116ceb9efc0ad8bb7cdeba08630d77b6754ac81fcad19adb1031d9c84bb4d7cbfcddd250675
7
+ data.tar.gz: fd9f66f85aa80d0247f9bbb753aad05d58b129723d36676ef09927091630a6e65025180dbb01fb7e9d31f4180933df5f98103c98ba71b0f4f2ff9ea639e31916
@@ -0,0 +1,80 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
8
+ runs-on: 'ubuntu-22.04'
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby: ['3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
13
+ rails: ['5.1', '5.2', '6.0', '6.1', '7.0', '7.1']
14
+ exclude:
15
+ - ruby: '3.2'
16
+ rails: '5.1'
17
+ - ruby: '3.2'
18
+ rails: '5.2'
19
+ - ruby: '3.2'
20
+ rails: '6.0'
21
+ - ruby: '3.2'
22
+ rails: '6.1'
23
+ - ruby: '3.1'
24
+ rails: '5.1'
25
+ - ruby: '3.1'
26
+ rails: '5.2'
27
+ - ruby: '3.1'
28
+ rails: '6.0'
29
+ - ruby: '3.0'
30
+ rails: '5.1'
31
+ - ruby: '3.0'
32
+ rails: '5.2'
33
+ - ruby: '2.6'
34
+ rails: '7.0'
35
+ - ruby: '2.5'
36
+ rails: '7.0'
37
+ - ruby: '2.5'
38
+ rails: '7.1'
39
+ - ruby: '2.6'
40
+ rails: '7.1'
41
+ env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
42
+ BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
43
+ steps:
44
+ - uses: actions/checkout@v3
45
+ - name: Set up Ruby ${{ matrix.ruby }}
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true # 'bundle install' and cache
50
+ rubygems: ${{ matrix.ruby == '2.5' && 'default' || 'latest' }}
51
+ - name: Copy config file
52
+ run: cp spec/support/sample.config.yml spec/support/config.yml
53
+ - name: Run tests
54
+ run: bundle exec rake
55
+
56
+ services:
57
+ mysql:
58
+ image: mysql:5.7
59
+ env:
60
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
61
+ ports:
62
+ - 3306:3306
63
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
64
+
65
+ postgres:
66
+ # Docker Hub image
67
+ image: postgres
68
+ # Provide the password for postgres
69
+ env:
70
+ POSTGRES_USER: postgres
71
+ POSTGRES_PASSWORD: postgres
72
+ ports:
73
+ - 5432:5432
74
+ # Set health checks to wait until postgres has started
75
+ options: >-
76
+ --health-cmd pg_isready
77
+ --health-interval 10s
78
+ --health-timeout 5s
79
+ --health-retries 5
80
+
data/.travis.yml CHANGED
@@ -15,9 +15,9 @@ gemfile:
15
15
  jobs:
16
16
  exclude: # Unsupported combos: https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
17
17
  - rvm: 3.0
18
- gemfiles/rails_5.1.gemfile
18
+ gemfile: gemfiles/rails_5.1.gemfile
19
19
  - rvm: 3.0
20
- gemfiles/rails_5.2.gemfile
20
+ gemfile: gemfiles/rails_5.2.gemfile
21
21
 
22
22
  before_install:
23
23
  - bin/setup
data/Appraisals CHANGED
@@ -1,15 +1,23 @@
1
1
  appraise "rails-5.1" do
2
- gem "rails", "~>5.1.0"
2
+ gem "rails", "~> 5.1.0"
3
3
  end
4
4
 
5
5
  appraise "rails-5.2" do
6
- gem "rails", "~>5.2.0"
6
+ gem "rails", "~> 5.2.0"
7
7
  end
8
8
 
9
9
  appraise "rails-6.0" do
10
- gem "rails", "~>6.0.0"
10
+ gem "rails", "~> 6.0.0"
11
11
  end
12
12
 
13
13
  appraise "rails-6.1" do
14
- gem "rails", "~>6.1.0"
14
+ gem "rails", "~> 6.1.0"
15
+ end
16
+
17
+ appraise "rails-7.0" do
18
+ gem "rails", "~> 7.0.0"
19
+ end
20
+
21
+ appraise "rails-7.1" do
22
+ gem "rails", "~> 7.1.0"
15
23
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Development (unreleased)
2
+
3
+ ## v2.1.0 2023-02-17
4
+
5
+ * Add Ruby 3.2 to CI matrix: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/79
6
+ * Add Rails 7.1 support: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/78
7
+ * Add WHERE clause to make `ruby-spanner-activerecord` happy: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/77
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ gemspec
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
6
 
7
7
  gem "rails", "~>5.2"
8
- gem "byebug"
9
8
 
10
9
  group :test do
11
10
  gem "simplecov", require: false
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Database Cleaner Adapter for ActiveRecord
2
2
 
3
- [![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-active_record.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-active_record)
3
+ [![Tests](https://github.com/DatabaseCleaner/database_cleaner-active_record/actions/workflows/ci.yml/badge.svg)](https://github.com/DatabaseCleaner/database_cleaner-active_record/actions/workflows/ci.yml)
4
4
  [![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-active_record/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-active_record)
5
5
  [![codecov](https://codecov.io/gh/DatabaseCleaner/database_cleaner-active_record/branch/master/graph/badge.svg)](https://codecov.io/gh/DatabaseCleaner/database_cleaner-active_record)
6
6
 
@@ -51,10 +51,10 @@ The truncation and deletion strategies may accept the following options:
51
51
 
52
52
  ```ruby
53
53
  # Only truncate the "users" table.
54
- DatabaseCleaner[:active_record].strategy = :truncation, only: ["users"]
54
+ DatabaseCleaner[:active_record].strategy = DatabaseCleaner::ActiveRecord::Truncation.new(only: ["users"])
55
55
 
56
56
  # Delete all tables except the "users" table.
57
- DatabaseCleaner[:active_record].strategy = :deletion, except: ["users"]
57
+ DatabaseCleaner[:active_record].strategy = DatabaseCleaner::ActiveRecord::Deletion.new(except: ["users"])
58
58
  ```
59
59
 
60
60
  * `:pre_count` - When set to `true` this will check each table for existing rows before truncating or deleting it. This can speed up test suites when many of the tables are never populated. Defaults to `false`. (Also, see the section on [What strategy is fastest?](#what-strategy-is-fastest))
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  f.match(%r{^(test|spec|features)/})
16
16
  end
17
17
  spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.executables = []
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "database_cleaner-core", "~>2.0.0"
@@ -3,8 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
- gem "rails", "~>5.1.0"
7
- gem "byebug"
6
+ gem "rails", "~> 5.1.0"
8
7
 
9
8
  group :test do
10
9
  gem "simplecov", require: false
@@ -3,8 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
- gem "rails", "~>5.2.0"
7
- gem "byebug"
6
+ gem "rails", "~> 5.2.0"
8
7
 
9
8
  group :test do
10
9
  gem "simplecov", require: false
@@ -3,8 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
- gem "rails", "~>6.0.0"
7
- gem "byebug"
6
+ gem "rails", "~> 6.0.0"
8
7
 
9
8
  group :test do
10
9
  gem "simplecov", require: false
@@ -3,12 +3,18 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
- gem "rails", "~>6.1.0"
7
- gem "byebug"
6
+ gem "rails", "~> 6.1.0"
8
7
 
9
8
  group :test do
10
9
  gem "simplecov", require: false
11
10
  gem "codecov", require: false
12
11
  end
13
12
 
13
+ if RUBY_VERSION >= '3.1'
14
+ gem 'net-smtp', require: false
15
+ gem 'net-imap', require: false
16
+ gem 'net-pop', require: false
17
+ end
18
+
19
+
14
20
  gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
+ gem "rails", "~> 7.0.0"
7
+
8
+ group :test do
9
+ gem "simplecov", require: false
10
+ gem "codecov", require: false
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
+ gem "rails", github: 'rails/rails' # "~> 7.1.0"
7
+
8
+ group :test do
9
+ gem "simplecov", require: false
10
+ gem "codecov", require: false
11
+ end
12
+
13
+ gemspec path: "../"
@@ -15,7 +15,11 @@ module DatabaseCleaner
15
15
 
16
16
  class Base < DatabaseCleaner::Strategy
17
17
  def self.migration_table_name
18
- ::ActiveRecord::SchemaMigration.table_name
18
+ if Gem::Version.new("6.0.0") <= ::ActiveRecord.version
19
+ ::ActiveRecord::Base.connection.schema_migration.table_name
20
+ else
21
+ ::ActiveRecord::SchemaMigration.table_name
22
+ end
19
23
  end
20
24
 
21
25
  def self.exclusion_condition(column_name)
@@ -46,7 +50,12 @@ module DatabaseCleaner
46
50
 
47
51
  def load_config
48
52
  if db != :default && db.is_a?(Symbol) && File.file?(DatabaseCleaner::ActiveRecord.config_file_location)
49
- connection_details = YAML::load(ERB.new(IO.read(DatabaseCleaner::ActiveRecord.config_file_location)).result)
53
+ connection_details =
54
+ if RUBY_VERSION.match?(/\A2\.5/)
55
+ YAML.safe_load(ERB.new(IO.read(DatabaseCleaner::ActiveRecord.config_file_location)).result, [], [], true)
56
+ else
57
+ YAML.safe_load(ERB.new(IO.read(DatabaseCleaner::ActiveRecord.config_file_location)).result, aliases: true)
58
+ end
50
59
  @connection_hash = valid_config(connection_details, db.to_s)
51
60
  end
52
61
  end
@@ -23,7 +23,7 @@ module DatabaseCleaner
23
23
  end
24
24
 
25
25
  def delete_table connection, table_name
26
- connection.execute("DELETE FROM #{connection.quote_table_name(table_name)}")
26
+ connection.execute("DELETE FROM #{connection.quote_table_name(table_name)} WHERE 1=1")
27
27
  end
28
28
 
29
29
  def tables_to_truncate(connection)
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module ActiveRecord
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_cleaner-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
8
8
  - Micah Geisel
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-05-08 00:00:00.000000000 Z
12
+ date: 2023-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: database_cleaner-core
@@ -145,10 +145,12 @@ executables: []
145
145
  extensions: []
146
146
  extra_rdoc_files: []
147
147
  files:
148
+ - ".github/workflows/ci.yml"
148
149
  - ".gitignore"
149
150
  - ".rspec"
150
151
  - ".travis.yml"
151
152
  - Appraisals
153
+ - CHANGELOG.md
152
154
  - Gemfile
153
155
  - LICENSE.txt
154
156
  - README.md
@@ -161,6 +163,8 @@ files:
161
163
  - gemfiles/rails_5.2.gemfile
162
164
  - gemfiles/rails_6.0.gemfile
163
165
  - gemfiles/rails_6.1.gemfile
166
+ - gemfiles/rails_7.0.gemfile
167
+ - gemfiles/rails_7.1.gemfile
164
168
  - lib/database_cleaner-active_record.rb
165
169
  - lib/database_cleaner/active_record.rb
166
170
  - lib/database_cleaner/active_record/base.rb
@@ -173,7 +177,7 @@ homepage: https://github.com/DatabaseCleaner/database_cleaner-active_record
173
177
  licenses:
174
178
  - MIT
175
179
  metadata: {}
176
- post_install_message:
180
+ post_install_message:
177
181
  rdoc_options: []
178
182
  require_paths:
179
183
  - lib
@@ -188,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
192
  - !ruby/object:Gem::Version
189
193
  version: '0'
190
194
  requirements: []
191
- rubygems_version: 3.1.4
192
- signing_key:
195
+ rubygems_version: 3.0.3
196
+ signing_key:
193
197
  specification_version: 4
194
198
  summary: Strategies for cleaning databases using ActiveRecord. Can be used to ensure
195
199
  a clean state for testing.