database_cleaner-core 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 +4 -4
- data/.github/workflows/ci.yml +39 -0
- data/CONTRIBUTE.markdown +3 -3
- data/History.rdoc +18 -0
- data/README.markdown +10 -6
- data/database_cleaner.gemspec +2 -2
- data/docker-compose.yml +7 -0
- data/lib/database_cleaner/cleaner.rb +1 -1
- data/lib/database_cleaner/cleaners.rb +19 -0
- data/lib/database_cleaner/core.rb +1 -0
- data/lib/database_cleaner/deprecation.rb +1 -1
- data/lib/database_cleaner/safeguard.rb +6 -4
- data/lib/database_cleaner/spec/database_helper.rb +2 -2
- data/lib/database_cleaner/version.rb +3 -1
- metadata +8 -7
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fae4c60d221b4cfe90b67d2a8d23882be2c9a5e6001604d58f747f8738106bc1
|
|
4
|
+
data.tar.gz: 36a358ad3e8e12ec27295191f946f2db05ff1a262ce33d587de638ed513adb99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73da7682fac422e5388a641adec17ea902e0f95c49c9bfc6cbb9e882b0dc17cf8fc758eed25a99db06705fb54a85cb20c078c864c4b576036edabc5bc6273428
|
|
7
|
+
data.tar.gz: 0c33ac598b9f762e821e3d0a23051b66decdb4aa9342019d4fa0f75865137b8e564024d87a82abebb5637aec25e5619bff635be4d8516e992a5bc5261eab063b
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
ruby-version:
|
|
12
|
+
- '3.3'
|
|
13
|
+
- '3.2'
|
|
14
|
+
- '3.1'
|
|
15
|
+
- '3.0'
|
|
16
|
+
- '2.7'
|
|
17
|
+
- '2.6'
|
|
18
|
+
- '2.5'
|
|
19
|
+
|
|
20
|
+
services:
|
|
21
|
+
redis:
|
|
22
|
+
image: redis
|
|
23
|
+
options: >-
|
|
24
|
+
--health-cmd "redis-cli ping"
|
|
25
|
+
--health-interval 10s
|
|
26
|
+
--health-timeout 5s
|
|
27
|
+
--health-retries 5
|
|
28
|
+
ports:
|
|
29
|
+
- 6379:6379
|
|
30
|
+
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v3
|
|
33
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
34
|
+
uses: ruby/setup-ruby@v1
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
37
|
+
bundler-cache: true # 'bundle install' and cache
|
|
38
|
+
- name: Run tests
|
|
39
|
+
run: bundle exec rake
|
data/CONTRIBUTE.markdown
CHANGED
|
@@ -12,10 +12,10 @@ upstream:
|
|
|
12
12
|
|
|
13
13
|
- `bundle install`
|
|
14
14
|
- Copy `spec/support/sample.config.yml` to `spec/support/config.yml` and edit it
|
|
15
|
-
- Run the tests with `bundle exec rspec`
|
|
15
|
+
- Run the tests with `bundle exec rspec` and `bundle exec cucumber`
|
|
16
16
|
|
|
17
|
-
Note that
|
|
18
|
-
|
|
17
|
+
Note that the Cucumber specs require `redis` to be running, you can either run it globally
|
|
18
|
+
on your system or use the provided `docker-compose.yml` file and run `docker compose up`.
|
|
19
19
|
|
|
20
20
|
## 3. Prepare your contribution
|
|
21
21
|
|
data/History.rdoc
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
== Development (unreleased)
|
|
2
2
|
|
|
3
|
+
== Chores
|
|
4
|
+
* Update CONTRIBUTE.md to mention Cucumber specs and Redis dependency https://github.com/DatabaseCleaner/database_cleaner/pull/721
|
|
5
|
+
|
|
6
|
+
== 2.1.0 2024-10-24
|
|
7
|
+
|
|
8
|
+
=== Changes
|
|
9
|
+
* Add support for trilogy: https://github.com/DatabaseCleaner/database_cleaner/pull/707
|
|
10
|
+
=== Chores
|
|
11
|
+
* Start testing with Ruby 3.3 in CI: https://github.com/DatabaseCleaner/database_cleaner/pull/710
|
|
12
|
+
* Point CI badge to GitHub Actions: https://github.com/DatabaseCleaner/database_cleaner/pull/706
|
|
13
|
+
=== Breaking changes
|
|
14
|
+
* Skip conventional sqlite:// URLs from safeguards: https://github.com/DatabaseCleaner/database_cleaner/pull/715
|
|
15
|
+
|
|
16
|
+
== 2.0.2 2023-03-10
|
|
17
|
+
|
|
18
|
+
== Bugfixes
|
|
19
|
+
* Dependency configuration -- relax dependencies with database_cleaner-active_record: https://github.com/DatabaseCleaner/database_cleaner/pull/699
|
|
20
|
+
|
|
3
21
|
== 2.0.1 2021-02-04
|
|
4
22
|
|
|
5
23
|
== Bugfixes
|
data/README.markdown
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Database Cleaner
|
|
2
2
|
|
|
3
|
-
[](https://github.com/DatabaseCleaner/database_cleaner/actions/workflows/ci.yml)
|
|
4
4
|
[](https://codeclimate.com/github/DatabaseCleaner/database_cleaner)
|
|
5
|
-
[](https://codecov.io/gh/DatabaseCleaner/database_cleaner)
|
|
6
6
|

|
|
7
7
|
[](https://dependabot.com/compatibility-score.html?dependency-name=database_cleaner&package-manager=bundler&version-scheme=semver)
|
|
8
8
|
|
|
@@ -75,11 +75,11 @@ DatabaseCleaner.clean
|
|
|
75
75
|
With the `:truncation` strategy you can also pass in options, for example:
|
|
76
76
|
|
|
77
77
|
```ruby
|
|
78
|
-
DatabaseCleaner.strategy = :truncation,
|
|
78
|
+
DatabaseCleaner.strategy = [:truncation, only: %w[widgets dogs some_other_table]]
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
```ruby
|
|
82
|
-
DatabaseCleaner.strategy = :truncation,
|
|
82
|
+
DatabaseCleaner.strategy = [:truncation, except: %w[widgets]]
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
(I should point out the truncation strategy will never truncate your schema_migrations table.)
|
|
@@ -300,10 +300,10 @@ DatabaseCleaner[:active_record].strategy = :transaction
|
|
|
300
300
|
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
|
301
301
|
|
|
302
302
|
# How to specify particular databases
|
|
303
|
-
DatabaseCleaner[:active_record,
|
|
303
|
+
DatabaseCleaner[:active_record, db: :two]
|
|
304
304
|
|
|
305
305
|
# You may also pass in the model directly:
|
|
306
|
-
DatabaseCleaner[:active_record,
|
|
306
|
+
DatabaseCleaner[:active_record, db: ModelWithDifferentConnection]
|
|
307
307
|
```
|
|
308
308
|
|
|
309
309
|
Usage beyond that remains the same with `DatabaseCleaner.start` calling any setup on the different configured databases, and `DatabaseCleaner.clean` executing afterwards.
|
|
@@ -353,6 +353,10 @@ DatabaseCleaner.url_allowlist = [
|
|
|
353
353
|
]
|
|
354
354
|
```
|
|
355
355
|
|
|
356
|
+
## CHANGELOG
|
|
357
|
+
|
|
358
|
+
See [HISTORY](History.rdoc) for details.
|
|
359
|
+
|
|
356
360
|
## COPYRIGHT
|
|
357
361
|
|
|
358
362
|
See [LICENSE](LICENSE) for details.
|
data/database_cleaner.gemspec
CHANGED
|
@@ -11,10 +11,10 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner"
|
|
12
12
|
spec.license = "MIT"
|
|
13
13
|
|
|
14
|
-
spec.metadata["changelog_uri"] = "https://github.com/DatabaseCleaner/database_cleaner/blob/
|
|
14
|
+
spec.metadata["changelog_uri"] = "https://github.com/DatabaseCleaner/database_cleaner/blob/main/History.rdoc"
|
|
15
15
|
|
|
16
16
|
spec.files = ["lib/database_cleaner.rb"]
|
|
17
17
|
spec.require_paths = ["lib"]
|
|
18
18
|
|
|
19
|
-
spec.add_dependency "database_cleaner-active_record", "
|
|
19
|
+
spec.add_dependency "database_cleaner-active_record", ">= 2", "< 3"
|
|
20
20
|
end
|
data/docker-compose.yml
ADDED
|
@@ -86,7 +86,7 @@ module DatabaseCleaner
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def orm_strategy(strategy)
|
|
89
|
-
strategy_module_name = strategy
|
|
89
|
+
strategy_module_name = camelize(strategy)
|
|
90
90
|
orm_module.const_get(strategy_module_name)
|
|
91
91
|
rescue NameError
|
|
92
92
|
available_strategies = self.class.available_strategies(orm_module)
|
|
@@ -13,6 +13,25 @@ module DatabaseCleaner
|
|
|
13
13
|
fetch([orm, opts]) { add_cleaner(orm, **opts) }
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# It returns a hash with all the strategies associated with
|
|
17
|
+
# all the cleaners.
|
|
18
|
+
#
|
|
19
|
+
# For example:
|
|
20
|
+
#
|
|
21
|
+
# ```
|
|
22
|
+
# cleaners.strategy
|
|
23
|
+
# => {
|
|
24
|
+
# :active_record_1 => :truncation,
|
|
25
|
+
# :active_record_2 => :truncation,
|
|
26
|
+
# :data_mapper_1 => :truncation
|
|
27
|
+
# }
|
|
28
|
+
# ```
|
|
29
|
+
#
|
|
30
|
+
# @return [Hash]
|
|
31
|
+
def strategy
|
|
32
|
+
transform_values(&:strategy)
|
|
33
|
+
end
|
|
34
|
+
|
|
16
35
|
def strategy=(strategy)
|
|
17
36
|
values.each { |cleaner| cleaner.strategy = strategy }
|
|
18
37
|
remove_duplicates
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "uri"
|
|
2
|
+
|
|
1
3
|
module DatabaseCleaner
|
|
2
4
|
class Safeguard
|
|
3
5
|
class Error < Exception
|
|
@@ -42,7 +44,8 @@ module DatabaseCleaner
|
|
|
42
44
|
LOCAL = %w(localhost 127.0.0.1)
|
|
43
45
|
|
|
44
46
|
def run
|
|
45
|
-
|
|
47
|
+
return if skip?
|
|
48
|
+
raise Error::RemoteDatabaseUrl if given?
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
private
|
|
@@ -53,12 +56,11 @@ module DatabaseCleaner
|
|
|
53
56
|
|
|
54
57
|
def remote?(url)
|
|
55
58
|
return false unless url
|
|
56
|
-
|
|
57
59
|
parsed = URI.parse(url)
|
|
58
|
-
return false if parsed.scheme == 'sqlite3
|
|
60
|
+
return false if parsed.scheme == 'sqlite' || parsed.scheme == 'sqlite3'
|
|
59
61
|
|
|
60
62
|
host = parsed.host
|
|
61
|
-
return false
|
|
63
|
+
return false if host.nil? || host.empty?
|
|
62
64
|
return false if LOCAL.include?(host)
|
|
63
65
|
return false if host.end_with? '.local'
|
|
64
66
|
true
|
|
@@ -4,7 +4,7 @@ module DatabaseCleaner
|
|
|
4
4
|
module Spec
|
|
5
5
|
class DatabaseHelper < Struct.new(:db)
|
|
6
6
|
def self.with_all_dbs &block
|
|
7
|
-
%w[mysql2 sqlite3 postgres].map(&:to_sym).each do |db|
|
|
7
|
+
%w[mysql2 sqlite3 postgres trilogy].map(&:to_sym).each do |db|
|
|
8
8
|
yield new(db)
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -43,7 +43,7 @@ module DatabaseCleaner
|
|
|
43
43
|
id_column = case db
|
|
44
44
|
when :sqlite3
|
|
45
45
|
"id INTEGER PRIMARY KEY AUTOINCREMENT"
|
|
46
|
-
when :mysql2
|
|
46
|
+
when :mysql2, :trilogy
|
|
47
47
|
"id INTEGER PRIMARY KEY AUTO_INCREMENT"
|
|
48
48
|
when :postgres
|
|
49
49
|
"id SERIAL PRIMARY KEY"
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: database_cleaner-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Mabey
|
|
8
8
|
- Ernesto Tagwerker
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-06-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -159,10 +159,10 @@ executables: []
|
|
|
159
159
|
extensions: []
|
|
160
160
|
extra_rdoc_files: []
|
|
161
161
|
files:
|
|
162
|
+
- ".github/workflows/ci.yml"
|
|
162
163
|
- ".gitignore"
|
|
163
164
|
- ".rspec"
|
|
164
165
|
- ".ruby-version.sample"
|
|
165
|
-
- ".travis.yml"
|
|
166
166
|
- ADAPTERS.md
|
|
167
167
|
- CONTRIBUTE.markdown
|
|
168
168
|
- Gemfile
|
|
@@ -175,6 +175,7 @@ files:
|
|
|
175
175
|
- cucumber.yml
|
|
176
176
|
- database_cleaner-core.gemspec
|
|
177
177
|
- database_cleaner.gemspec
|
|
178
|
+
- docker-compose.yml
|
|
178
179
|
- lib/database_cleaner-core.rb
|
|
179
180
|
- lib/database_cleaner/cleaner.rb
|
|
180
181
|
- lib/database_cleaner/cleaners.rb
|
|
@@ -193,7 +194,7 @@ homepage: https://github.com/DatabaseCleaner/database_cleaner
|
|
|
193
194
|
licenses:
|
|
194
195
|
- MIT
|
|
195
196
|
metadata: {}
|
|
196
|
-
post_install_message:
|
|
197
|
+
post_install_message:
|
|
197
198
|
rdoc_options: []
|
|
198
199
|
require_paths:
|
|
199
200
|
- lib
|
|
@@ -208,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
208
209
|
- !ruby/object:Gem::Version
|
|
209
210
|
version: '0'
|
|
210
211
|
requirements: []
|
|
211
|
-
rubygems_version: 3.
|
|
212
|
-
signing_key:
|
|
212
|
+
rubygems_version: 3.5.10
|
|
213
|
+
signing_key:
|
|
213
214
|
specification_version: 4
|
|
214
215
|
summary: Strategies for cleaning databases. Can be used to ensure a clean slate for
|
|
215
216
|
testing.
|