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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c30dde1a5104c77a1bf907b7d5d5bb8aa187776246b8b02639d0ea8e352fd1d
4
- data.tar.gz: 982552da4f5c169ddf5a0d16c9703eb2b73623e1330c476dd8116683409951fd
3
+ metadata.gz: f4009a9e2733cc775473d2357dedf4005e14abc0be5a1b2841241dc9ac0a8afd
4
+ data.tar.gz: 89a9750d057f21fb543f2f7ca93926c48df4e2b08fec1276589063ca42254146
5
5
  SHA512:
6
- metadata.gz: 9d46caf98521a0a53b67655e1eb55947108b13cf37b2ce8398fcdc53f34b334c51fa34acf65135c04689a1022394a396dc0648c0406d2d92a147c005bf488551
7
- data.tar.gz: fd15224bc593acc67996d9a2c04840df1e95d3eafb49a68ba6d73dd64c0e92cd6984d9bb7b972ed7d6ef6063d67cd918ba1474630c8675520e932ef57c267108
6
+ metadata.gz: 0daef1af314e3a7f432257e7b6051076d7963e685861b5b232811bcb9bcc6cdf0d9a020b980536ca9533c804c0aebe258dbaf6ef642a96c56950be6faf50ce3a
7
+ data.tar.gz: 3166ab8f41926b33a005f458ad601de7f2cc0fff3c2a36151a5c217271fe3dd84a7db332c448ece8aafab396d5e730c3b4760acfc5b56edd6129201e12977f86
@@ -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.3'
30
+ - ruby: '3.4'
28
31
  rails: 'edge'
29
32
  channel: 'experimental'
30
- - ruby: '3.2'
33
+ - ruby: '3.3'
31
34
  rails: 'edge'
32
35
  channel: 'experimental'
33
- - ruby: '3.1'
36
+ - ruby: '3.2'
34
37
  rails: 'edge'
35
38
  channel: 'experimental'
36
39
 
37
40
  exclude:
38
- - ruby: '3.3'
39
- rails: '7.0' # TODO: works on 7-0-stable branch, remove after a 7.0.x patch release
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
@@ -102,6 +102,10 @@ test:
102
102
  min_messages: WARNING
103
103
  </pre>
104
104
 
105
+ ## Development
106
+
107
+ Check the CONTRIBUTE.md file for instructions running tests with and withour Docker.
108
+
105
109
  ## COPYRIGHT
106
110
 
107
111
  See [LICENSE](LICENSE) for details.
@@ -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.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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.beta2"
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: "../"
@@ -4,6 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6
6
  gem "rails", github: "rails/rails"
7
+ gem "logger"
8
+ gem "mutex_m"
9
+ gem "bigdecimal"
7
10
 
8
11
  group :test do
9
12
  gem "simplecov", require: false
@@ -9,6 +9,8 @@ module DatabaseCleaner
9
9
  delete_tables(connection, tables_to_clean(connection))
10
10
  end
11
11
  end
12
+
13
+ connection_class.connection_pool.release_connection
12
14
  end
13
15
 
14
16
  private
@@ -22,6 +22,8 @@ module DatabaseCleaner
22
22
  connection.rollback_transaction
23
23
  end
24
24
  end
25
+
26
+ connection_class.connection_pool.release_connection
25
27
  end
26
28
  end
27
29
  end
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module ActiveRecord
3
- VERSION = "2.2.1"
3
+ VERSION = "2.2.2"
4
4
  end
5
5
  end
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.1
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-05-13 00:00:00.000000000 Z
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.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.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