database_cleaner-active_record 2.2.1 → 2.2.2
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 +4 -4
- data/.github/workflows/ci.yml +14 -7
- data/CHANGELOG.md +11 -1
- data/CONTRIBUTE.md +45 -0
- data/Dockerfile +19 -0
- data/README.md +4 -0
- data/database_cleaner-active_record.gemspec +3 -1
- data/docker-compose.db.yml +19 -0
- data/docker-compose.yml +26 -0
- data/gemfiles/rails_6.1.gemfile +4 -0
- data/gemfiles/rails_7.0.gemfile +4 -0
- data/gemfiles/rails_7.1.gemfile +3 -0
- data/gemfiles/rails_7.2.gemfile +4 -1
- data/gemfiles/rails_8.0.gemfile +16 -0
- data/gemfiles/rails_edge.gemfile +3 -0
- data/lib/database_cleaner/active_record/deletion.rb +2 -0
- data/lib/database_cleaner/active_record/transaction.rb +2 -0
- data/lib/database_cleaner/active_record/truncation.rb +9 -7
- data/lib/database_cleaner/active_record/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4009a9e2733cc775473d2357dedf4005e14abc0be5a1b2841241dc9ac0a8afd
|
4
|
+
data.tar.gz: 89a9750d057f21fb543f2f7ca93926c48df4e2b08fec1276589063ca42254146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0daef1af314e3a7f432257e7b6051076d7963e685861b5b232811bcb9bcc6cdf0d9a020b980536ca9533c804c0aebe258dbaf6ef642a96c56950be6faf50ce3a
|
7
|
+
data.tar.gz: 3166ab8f41926b33a005f458ad601de7f2cc0fff3c2a36151a5c217271fe3dd84a7db332c448ece8aafab396d5e730c3b4760acfc5b56edd6129201e12977f86
|
data/.github/workflows/ci.yml
CHANGED
@@ -9,14 +9,17 @@ jobs:
|
|
9
9
|
strategy:
|
10
10
|
fail-fast: false
|
11
11
|
matrix:
|
12
|
-
ruby: ['3.3', '3.2', '3.1']
|
13
|
-
rails: ['6.1', '7.0', '7.1', '7.2']
|
12
|
+
ruby: ['3.4', '3.3', '3.2', '3.1']
|
13
|
+
rails: ['6.1', '7.0', '7.1', '7.2', '8.0']
|
14
14
|
channel: ['stable']
|
15
15
|
|
16
16
|
include:
|
17
17
|
- ruby: 'ruby-head'
|
18
18
|
rails: 'edge'
|
19
19
|
channel: 'experimental'
|
20
|
+
- ruby: 'ruby-head'
|
21
|
+
rails: '8.0'
|
22
|
+
channel: 'experimental'
|
20
23
|
- ruby: 'ruby-head'
|
21
24
|
rails: '7.2'
|
22
25
|
channel: 'experimental'
|
@@ -24,25 +27,29 @@ jobs:
|
|
24
27
|
rails: '7.1'
|
25
28
|
channel: 'experimental'
|
26
29
|
|
27
|
-
- ruby: '3.
|
30
|
+
- ruby: '3.4'
|
28
31
|
rails: 'edge'
|
29
32
|
channel: 'experimental'
|
30
|
-
- ruby: '3.
|
33
|
+
- ruby: '3.3'
|
31
34
|
rails: 'edge'
|
32
35
|
channel: 'experimental'
|
33
|
-
- ruby: '3.
|
36
|
+
- ruby: '3.2'
|
34
37
|
rails: 'edge'
|
35
38
|
channel: 'experimental'
|
36
39
|
|
37
40
|
exclude:
|
38
|
-
- ruby: '3.
|
39
|
-
rails: '
|
41
|
+
- ruby: '3.4'
|
42
|
+
rails: '6.1'
|
43
|
+
|
40
44
|
- ruby: '3.3'
|
41
45
|
rails: '6.1'
|
42
46
|
|
43
47
|
- ruby: '3.2'
|
44
48
|
rails: '6.1'
|
45
49
|
|
50
|
+
- ruby: '3.1'
|
51
|
+
rails: '8.0'
|
52
|
+
|
46
53
|
continue-on-error: ${{ matrix.channel != 'stable' }}
|
47
54
|
|
48
55
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Development (unreleased)
|
2
2
|
|
3
|
+
## v2.2.2 2025-07-30
|
4
|
+
|
5
|
+
* Release database connections after cleaning: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/122
|
6
|
+
* Provide a 'Changelog' link on Rubygems: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/114
|
7
|
+
* Fix bundling and CONTRIBUTE.md instructions: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/123
|
8
|
+
* https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/121 by @etagwerker
|
9
|
+
* Fix order of arguments in `truncate_tables` expectation https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/124
|
10
|
+
* Add Docker to make it easier to run tests locally for maintainers and contributors https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/109
|
11
|
+
* Allow truncation option https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/121 by @etagwerker
|
12
|
+
|
3
13
|
## v2.2.1 2025-05-13
|
4
14
|
|
5
15
|
* https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/111 by @tagliala
|
@@ -25,4 +35,4 @@
|
|
25
35
|
|
26
36
|
* Add Ruby 3.2 to CI matrix: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/79
|
27
37
|
* Add Rails 7.1 support: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/78
|
28
|
-
* Add WHERE clause to make `ruby-spanner-activerecord` happy: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/77
|
38
|
+
* Add WHERE clause to make `ruby-spanner-activerecord` happy: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/77
|
data/CONTRIBUTE.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Guidelines for contributing
|
2
|
+
|
3
|
+
## 1. Fork & Clone
|
4
|
+
|
5
|
+
Since you probably don't have rights to the main repo, you should Fork it (big
|
6
|
+
button up top). After that, clone your fork locally and optionally add an
|
7
|
+
upstream:
|
8
|
+
|
9
|
+
git remote add upstream git@github.com:DatabaseCleaner/database_cleaner-active_record.git
|
10
|
+
|
11
|
+
## 2. Make sure the tests run fine
|
12
|
+
|
13
|
+
The gem uses Appraisal to configure different Gemfiles to test different Rails versions.
|
14
|
+
|
15
|
+
### Run tests without Docker (or using Docker only for the databases)
|
16
|
+
|
17
|
+
- You can run all the databases through docker if needed with `docker compose -f docker-compose.db.yml up` (you can also have them running on your system, just comment out the ones you don't need from the `docker-compose.db.yml` file)
|
18
|
+
- Copy `spec/support/sample.config.yml` to `spec/support/config.yml` and edit it as needed
|
19
|
+
- `BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bundle install` (change `6.1` with any version from the `gemfiles` directory)
|
20
|
+
- `BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bundle exec rake`
|
21
|
+
|
22
|
+
Note that if you don't have all the supported databases installed and running,
|
23
|
+
some tests will fail.
|
24
|
+
|
25
|
+
> Check the `.github/workflows/ci.yml` file for different combinations of Ruby and Rails that are expected to work
|
26
|
+
|
27
|
+
### Run tests with Docker
|
28
|
+
|
29
|
+
- Open `docker-compose.yml` and configure the Ruby version and Gemfile file to use
|
30
|
+
- Copy `spec/support/sample.docker.config.yml` to `spec/support/config.yml` (not this config file is specific for the Docker setup)
|
31
|
+
- Run `docker compose up` to start the container, run the tests, and exit
|
32
|
+
- Run `docker compose run ruby bash` to open `bash` inside the container for more control, run `rake` to run the tests
|
33
|
+
|
34
|
+
> Note that the code is mounted inside the docker container, so changes in the container will reflect in the code. There's no need to re-build the container for code changes, but changing the Ruby version or Gemfile in the docker-compose.yml will require a container re-build with `docker compose build --no-cache`
|
35
|
+
|
36
|
+
> Check the `.github/workflows/ci.yml` file for different combinations of Ruby and Rails that are expected to work
|
37
|
+
|
38
|
+
## 3. Prepare your contribution
|
39
|
+
|
40
|
+
This is all up to you but a few points should be kept in mind:
|
41
|
+
|
42
|
+
- Please write tests for your contribution
|
43
|
+
- Make sure that previous tests still pass
|
44
|
+
- Push it to a branch of your fork
|
45
|
+
- Submit a pull request
|
data/Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ARG RUBY_VERSION=3.3
|
2
|
+
FROM ruby:${RUBY_VERSION}
|
3
|
+
|
4
|
+
# Set the working directory in the container
|
5
|
+
WORKDIR /app
|
6
|
+
|
7
|
+
# Copy the current directory contents into the container at /app
|
8
|
+
# This is copied so we can bundle the application, but it's replaced
|
9
|
+
# by a mounted volume with the current code when executed with docker compose
|
10
|
+
COPY . /app
|
11
|
+
|
12
|
+
ARG BUNDLE_GEMFILE=Gemfile
|
13
|
+
ENV BUNDLE_GEMFILE=${BUNDLE_GEMFILE}
|
14
|
+
|
15
|
+
# Install any needed packages specified in Gemfile
|
16
|
+
RUN ./bin/setup
|
17
|
+
|
18
|
+
# Command to run the application
|
19
|
+
CMD ["bash"]
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = []
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "database_cleaner-core", "~>2.0
|
21
|
+
spec.add_dependency "database_cleaner-core", "~>2.0"
|
22
22
|
spec.add_dependency "activerecord", ">= 5.a"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "pg"
|
30
30
|
spec.add_development_dependency "sqlite3"
|
31
31
|
spec.add_development_dependency "trilogy"
|
32
|
+
|
33
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/blob/main/CHANGELOG.md"
|
32
34
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
services:
|
2
|
+
postgres:
|
3
|
+
image: postgres:16 # specify the version needed for a given app
|
4
|
+
environment:
|
5
|
+
- POSTGRES_PASSWORD=postgres # this is required
|
6
|
+
ports:
|
7
|
+
- "127.0.0.1:5432:5432" # so we can use `localhost` as the host
|
8
|
+
mysql:
|
9
|
+
image: mysql:5.7
|
10
|
+
environment:
|
11
|
+
- MYSQL_ROOT_PASSWORD=mysql
|
12
|
+
ports:
|
13
|
+
- "127.0.0.1:3306:3306"
|
14
|
+
redis:
|
15
|
+
image: redis:6.2-alpine
|
16
|
+
restart: always
|
17
|
+
ports:
|
18
|
+
- "127.0.0.1:6379:6379"
|
19
|
+
command: redis-server --save 20 1 --loglevel warning
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
services:
|
2
|
+
postgres:
|
3
|
+
image: postgres:16 # specify the version needed for a given app
|
4
|
+
environment:
|
5
|
+
- POSTGRES_PASSWORD=postgres # this is required
|
6
|
+
mysql:
|
7
|
+
image: mysql:5.7
|
8
|
+
environment:
|
9
|
+
- MYSQL_ROOT_PASSWORD=mysql
|
10
|
+
redis:
|
11
|
+
image: redis:6.2-alpine
|
12
|
+
restart: always
|
13
|
+
command: redis-server --save 20 1 --loglevel warning
|
14
|
+
ruby:
|
15
|
+
build:
|
16
|
+
context: .
|
17
|
+
args:
|
18
|
+
BUNDLE_GEMFILE: gemfiles/rails_7.2.gemfile # Manually change this based on the desired Rails version
|
19
|
+
RUBY_VERSION: 3.3 # Manually change this based on the desired Ruby version
|
20
|
+
volumes:
|
21
|
+
- ".:/app:delegated"
|
22
|
+
command: rake
|
23
|
+
depends_on:
|
24
|
+
- mysql
|
25
|
+
- postgres
|
26
|
+
- redis
|
data/gemfiles/rails_6.1.gemfile
CHANGED
@@ -5,6 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
|
6
6
|
gem "rails", "~> 6.1.0"
|
7
7
|
gem "sqlite3", "~> 1.5"
|
8
|
+
gem "concurrent-ruby", "1.3.4"
|
9
|
+
gem "logger"
|
10
|
+
gem "mutex_m"
|
11
|
+
gem "bigdecimal"
|
8
12
|
|
9
13
|
group :test do
|
10
14
|
gem "simplecov", require: false
|
data/gemfiles/rails_7.0.gemfile
CHANGED
@@ -5,6 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
|
6
6
|
gem "rails", "~> 7.0.0"
|
7
7
|
gem "sqlite3", "~> 1.7"
|
8
|
+
gem "concurrent-ruby", "1.3.4"
|
9
|
+
gem "logger"
|
10
|
+
gem "mutex_m"
|
11
|
+
gem "bigdecimal"
|
8
12
|
|
9
13
|
group :test do
|
10
14
|
gem "simplecov", require: false
|
data/gemfiles/rails_7.1.gemfile
CHANGED
@@ -5,6 +5,9 @@ source "https://rubygems.org"
|
|
5
5
|
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
|
6
6
|
gem "rails", "~> 7.1.0"
|
7
7
|
gem "sqlite3", "~> 1.7"
|
8
|
+
gem "logger"
|
9
|
+
gem "mutex_m"
|
10
|
+
gem "bigdecimal"
|
8
11
|
|
9
12
|
group :test do
|
10
13
|
gem "simplecov", require: false
|
data/gemfiles/rails_7.2.gemfile
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
|
6
|
-
gem "rails", "~> 7.2.0
|
6
|
+
gem "rails", "~> 7.2.0"
|
7
|
+
gem "logger"
|
8
|
+
gem "mutex_m"
|
9
|
+
gem "bigdecimal"
|
7
10
|
|
8
11
|
group :test do
|
9
12
|
gem "simplecov", require: false
|
@@ -0,0 +1,16 @@
|
|
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", "~> 8.0"
|
7
|
+
gem "logger"
|
8
|
+
gem "mutex_m"
|
9
|
+
gem "bigdecimal"
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem "simplecov", require: false
|
13
|
+
gem "codecov", require: false
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec path: "../"
|
data/gemfiles/rails_edge.gemfile
CHANGED
@@ -21,11 +21,13 @@ module DatabaseCleaner
|
|
21
21
|
def clean
|
22
22
|
connection.disable_referential_integrity do
|
23
23
|
if pre_count? && connection.respond_to?(:pre_count_truncate_tables)
|
24
|
-
connection.pre_count_truncate_tables(tables_to_clean(connection))
|
24
|
+
connection.pre_count_truncate_tables(tables_to_clean(connection), { truncate_option: @truncate_option })
|
25
25
|
else
|
26
26
|
connection.truncate_tables(tables_to_clean(connection), { truncate_option: @truncate_option })
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
connection_class.connection_pool.release_connection
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -109,8 +111,8 @@ module DatabaseCleaner
|
|
109
111
|
end
|
110
112
|
|
111
113
|
module AbstractMysqlAdapter
|
112
|
-
def pre_count_truncate_tables(tables)
|
113
|
-
truncate_tables(pre_count_tables(tables))
|
114
|
+
def pre_count_truncate_tables(tables, opts = {})
|
115
|
+
truncate_tables(pre_count_tables(tables), opts)
|
114
116
|
end
|
115
117
|
|
116
118
|
def pre_count_tables(tables)
|
@@ -157,8 +159,8 @@ module DatabaseCleaner
|
|
157
159
|
tables.each { |t| truncate_table(t) }
|
158
160
|
end
|
159
161
|
|
160
|
-
def pre_count_truncate_tables(tables)
|
161
|
-
truncate_tables(pre_count_tables(tables))
|
162
|
+
def pre_count_truncate_tables(tables, opts = {})
|
163
|
+
truncate_tables(pre_count_tables(tables), opts)
|
162
164
|
end
|
163
165
|
|
164
166
|
def pre_count_tables(tables)
|
@@ -200,8 +202,8 @@ module DatabaseCleaner
|
|
200
202
|
execute("TRUNCATE TABLE #{table_names.map{|name| quote_table_name(name)}.join(', ')} RESTART IDENTITY #{opts[:truncate_option]};")
|
201
203
|
end
|
202
204
|
|
203
|
-
def pre_count_truncate_tables(tables)
|
204
|
-
truncate_tables(pre_count_tables(tables))
|
205
|
+
def pre_count_truncate_tables(tables, opts = {})
|
206
|
+
truncate_tables(pre_count_tables(tables), opts)
|
205
207
|
end
|
206
208
|
|
207
209
|
def pre_count_tables(tables)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_cleaner-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernesto Tagwerker
|
8
8
|
- Micah Geisel
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_cleaner-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
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: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,6 +163,8 @@ files:
|
|
163
163
|
- ".rspec"
|
164
164
|
- Appraisals
|
165
165
|
- CHANGELOG.md
|
166
|
+
- CONTRIBUTE.md
|
167
|
+
- Dockerfile
|
166
168
|
- Gemfile
|
167
169
|
- LICENSE.txt
|
168
170
|
- README.md
|
@@ -170,11 +172,14 @@ files:
|
|
170
172
|
- bin/console
|
171
173
|
- bin/setup
|
172
174
|
- database_cleaner-active_record.gemspec
|
175
|
+
- docker-compose.db.yml
|
176
|
+
- docker-compose.yml
|
173
177
|
- gemfiles/.bundle/config
|
174
178
|
- gemfiles/rails_6.1.gemfile
|
175
179
|
- gemfiles/rails_7.0.gemfile
|
176
180
|
- gemfiles/rails_7.1.gemfile
|
177
181
|
- gemfiles/rails_7.2.gemfile
|
182
|
+
- gemfiles/rails_8.0.gemfile
|
178
183
|
- gemfiles/rails_edge.gemfile
|
179
184
|
- lib/database_cleaner-active_record.rb
|
180
185
|
- lib/database_cleaner/active_record.rb
|
@@ -187,7 +192,8 @@ files:
|
|
187
192
|
homepage: https://github.com/DatabaseCleaner/database_cleaner-active_record
|
188
193
|
licenses:
|
189
194
|
- MIT
|
190
|
-
metadata:
|
195
|
+
metadata:
|
196
|
+
changelog_uri: https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/main/CHANGELOG.md
|
191
197
|
rdoc_options: []
|
192
198
|
require_paths:
|
193
199
|
- lib
|