database_cleaner-core 2.0.0.beta2 → 2.0.0

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: eacd8a1e863364bb678724f33c44ba361e1fbdc77066da69b4b92794e3528c14
4
- data.tar.gz: 978fd0a42dd410ee1bb8282fdd29654582a88afe1a6709b4b23fa33c418ff0bc
3
+ metadata.gz: 10b3a62dc4a34477c00150b01b020e1c8b3a36bfff77674e66c281b6a101187d
4
+ data.tar.gz: 0894cd2cf9a69c054ef04138fba09ec20a995e11aedbfa64b40177d8fb45d238
5
5
  SHA512:
6
- metadata.gz: 0eb27aff631629df80bcf9234c8fd923f8946727592688372233c101f9ae2c839b00d74c12dd3c847047d4fab95694a74d492378cc73aec1bb8cf55a5704fc04
7
- data.tar.gz: aeb081d591c2619f37575b6b4e714cac728c0de01de73de416ecc641782e3ccf3a1b7d1abdf61a19983258cf95b47e719409154747a31a456ee5a6e85158567f
6
+ metadata.gz: e4bdb0c48d6e51c3f7ff56284de6ddca71943fb0e93b90a51990b66e575b9175292afac2e778e6d815b969cb31a1522ce96ee75af7e16ec016081de4f9d8ab8d
7
+ data.tar.gz: 26e519e860c44e520feb51245ca44d3c4c0f1b7e8ef6d8af76dcbc8bd8dad35b0e6625855e98e07bd7d94dcccda9728c1bec443d139dbefdfe2f304a157d4e14
@@ -26,8 +26,6 @@ You need to add a couple of dependecies to `.gemspec`:
26
26
  spec.add_dependency "orm_name", "some version if required"
27
27
  ```
28
28
 
29
- ####
30
-
31
29
  ### File structure
32
30
 
33
31
  Inside the `lib/database_cleaner/orm_name` directory, you will need to create a few files:
@@ -1,3 +1,15 @@
1
+ == Development (unreleased)
2
+
3
+ == 2.0.0 2021-01-31
4
+
5
+ === Changes
6
+ * Rename `url_whitelist` to `url_allowlist`
7
+ * Allowlist now supports regular expressions
8
+ * Fixed Ruby 2.7 deprecation warnings
9
+
10
+ === Breaking changes
11
+ * Failed checks against the allowlist now raise `UrlNotAllowed` rather than `NotWhitelistedUrl`
12
+
1
13
  == 2.0.0.beta2 2020-05-30
2
14
 
3
15
  === Features
@@ -17,7 +29,7 @@
17
29
  * remove all deprecated code and get the specs passing again.
18
30
  * Split off all adapter gems into their own repos: https://github.com/DatabaseCleaner/database_cleaner/pull/620
19
31
 
20
- == 1.99.0.beta 2020-05-30
32
+ == 1.99.0 2021-01-31
21
33
 
22
34
  == Changes
23
35
  * Remove unnecessary dependency on database_cleaner-mongo from database_cleaner-mongoid: @botandrose
@@ -137,7 +137,7 @@ So what is fastest out of `:deletion` and `:truncation`? Well, it depends on you
137
137
 
138
138
  Some people report much faster speeds with `:deletion` while others say `:truncation` is faster for them. The best approach therefore is it try all options on your test suite and see what is faster.
139
139
 
140
- If you are using ActiveRecord then take a look at the [additional options](#additional-activerecord-options-for-truncation) available for `:truncation`.
140
+ If you are using ActiveRecord then take a look at the [additional options](https://github.com/DatabaseCleaner/database_cleaner-active_record#strategy-configuration-options) available for `:truncation`.
141
141
 
142
142
  Database Cleaner also includes a `null` strategy (that does no cleaning at all) which can be used with any ORM library.
143
143
  You can also explicitly use it by setting your strategy to `nil`.
@@ -323,7 +323,7 @@ After copying and pasting code to do this several times I decided to package it
323
323
 
324
324
  DatabaseCleaner comes with safeguards against:
325
325
 
326
- * Running in production (checking for `ENV`, `RACK_ENV`, and `RAILS_ENV`)
326
+ * Running in production (checking for `ENV`, `APP_ENV`, `RACK_ENV`, and `RAILS_ENV`)
327
327
  * Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`, `.local` or `127.0.0.1`)
328
328
 
329
329
  Both safeguards can be disabled separately as follows.
@@ -342,11 +342,20 @@ DatabaseCleaner.allow_production = true
342
342
  DatabaseCleaner.allow_remote_database_url = true
343
343
  ```
344
344
 
345
- In Ruby, a URL whitelist can be specified. When specified, DatabaseCleaner will only allow `DATABASE_URL` to be equal
346
- to one of the values specified in the url whitelist like so:
345
+ In Ruby, a URL allowlist can be specified. When specified, DatabaseCleaner will only allow `DATABASE_URL` to be equal
346
+ to one of the values specified in the url allowlist like so:
347
347
 
348
348
  ```ruby
349
- DatabaseCleaner.url_whitelist = ['postgres://postgres@localhost', 'postgres://foo@bar']
349
+ DatabaseCleaner.url_allowlist = ['postgres://postgres@localhost', 'postgres://foo@bar']
350
+ ```
351
+
352
+ Allowlist elements are matched with case equality (`===`), so regular expressions or procs may be used:
353
+
354
+ ```ruby
355
+ DatabaseCleaner.url_allowlist = [
356
+ %r{^postgres://postgres@localhost}, # match any db with this prefix
357
+ proc {|uri| URI.parse(uri).user == "test" } # match any db authenticating with the 'test' user
358
+ ]
350
359
  ```
351
360
 
352
361
  ## COPYRIGHT
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "listen"
25
25
  spec.add_development_dependency "rspec"
26
26
 
27
- spec.add_development_dependency "cucumber"
27
+ spec.add_development_dependency "cucumber", "~>3.0"
28
28
  spec.add_development_dependency "activesupport"
29
29
  spec.add_development_dependency "database_cleaner-active_record"
30
30
  spec.add_development_dependency "sqlite3"
@@ -2,9 +2,7 @@ require_relative "./lib/database_cleaner/version"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "database_cleaner"
5
- # FIXME temporarily hardcode to different version since core is at 2.0.0.beta2, but this gem only is at 2.0.0.beta
6
- # spec.version = DatabaseCleaner::VERSION
7
- spec.version = "2.0.0.beta"
5
+ spec.version = DatabaseCleaner::VERSION
8
6
  spec.authors = ["Ben Mabey", "Ernesto Tagwerker", "Micah Geisel"]
9
7
  spec.email = ["ernesto@ombulabs.com"]
10
8
 
@@ -18,5 +16,5 @@ Gem::Specification.new do |spec|
18
16
  spec.files = ["lib/database_cleaner.rb"]
19
17
  spec.require_paths = ["lib"]
20
18
 
21
- spec.add_dependency "database_cleaner-active_record", "~>2.0.0.beta2"
19
+ spec.add_dependency "database_cleaner-active_record", "~>2.0.0"
22
20
  end
@@ -7,10 +7,10 @@ module DatabaseCleaner
7
7
  end
8
8
 
9
9
  # FIXME this method conflates creation with lookup... both a command and a query. yuck.
10
- def [](orm, opts = {})
10
+ def [](orm, **opts)
11
11
  raise ArgumentError if orm.nil?
12
- fetch([orm, opts]) { add_cleaner(orm, opts) }
13
- end
12
+ fetch([orm, opts]) { add_cleaner(orm, **opts) }
13
+ end
14
14
 
15
15
  def strategy=(strategy)
16
16
  values.each { |cleaner| cleaner.strategy = strategy }
@@ -37,8 +37,8 @@ module DatabaseCleaner
37
37
 
38
38
  private
39
39
 
40
- def add_cleaner(orm, opts = {})
41
- self[[orm, opts]] = Cleaner.new(orm, opts)
40
+ def add_cleaner(orm, **opts)
41
+ self[[orm, opts]] = Cleaner.new(orm, **opts)
42
42
  end
43
43
 
44
44
  def remove_duplicates
@@ -14,7 +14,10 @@ module DatabaseCleaner
14
14
  :cleaning,
15
15
  ] => :cleaners
16
16
 
17
- attr_accessor :allow_remote_database_url, :allow_production, :url_whitelist
17
+ attr_accessor :allow_remote_database_url, :allow_production, :url_allowlist
18
+
19
+ alias :url_whitelist :url_allowlist
20
+ alias :url_whitelist= :url_allowlist=
18
21
 
19
22
  def cleaners
20
23
  @cleaners ||= Cleaners.new
@@ -3,11 +3,11 @@ module DatabaseCleaner
3
3
  def start
4
4
  # no-op
5
5
  end
6
-
6
+
7
7
  def db=(db)
8
8
  # no-op
9
9
  end
10
-
10
+
11
11
  def clean
12
12
  # no-op
13
13
  end
@@ -13,27 +13,27 @@ module DatabaseCleaner
13
13
  end
14
14
  end
15
15
 
16
- class NotWhitelistedUrl < Error
16
+ class UrlNotAllowed < Error
17
17
  def initialize
18
- super("ENV['DATABASE_URL'] is set to a URL that is not on the whitelist. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards")
18
+ super("ENV['DATABASE_URL'] is set to a URL that is not on the allowlist. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards")
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
- class WhitelistedUrl
23
+ class AllowedUrl
24
24
  def run
25
25
  return if skip?
26
- raise Error::NotWhitelistedUrl if database_url_not_whitelisted?
26
+ raise Error::UrlNotAllowed if database_url_not_allowed?
27
27
  end
28
28
 
29
29
  private
30
30
 
31
- def database_url_not_whitelisted?
32
- !DatabaseCleaner.url_whitelist.include?(ENV['DATABASE_URL'])
31
+ def database_url_not_allowed?
32
+ !DatabaseCleaner.url_allowlist.any? {|allowed| allowed === ENV['DATABASE_URL'] }
33
33
  end
34
34
 
35
35
  def skip?
36
- !DatabaseCleaner.url_whitelist
36
+ !DatabaseCleaner.url_allowlist
37
37
  end
38
38
  end
39
39
 
@@ -67,12 +67,12 @@ module DatabaseCleaner
67
67
  def skip?
68
68
  ENV['DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL'] ||
69
69
  DatabaseCleaner.allow_remote_database_url ||
70
- DatabaseCleaner.url_whitelist
70
+ DatabaseCleaner.url_allowlist
71
71
  end
72
72
  end
73
73
 
74
74
  class Production
75
- KEYS = %w(ENV RACK_ENV RAILS_ENV)
75
+ KEYS = %w(ENV APP_ENV RACK_ENV RAILS_ENV)
76
76
 
77
77
  def run
78
78
  raise Error::ProductionEnv.new(key) if !skip? && given?
@@ -97,7 +97,7 @@ module DatabaseCleaner
97
97
  CHECKS = [
98
98
  RemoteDatabaseUrl,
99
99
  Production,
100
- WhitelistedUrl
100
+ AllowedUrl
101
101
  ]
102
102
 
103
103
  def run
@@ -1,3 +1,3 @@
1
1
  module DatabaseCleaner
2
- VERSION = "2.0.0.beta2"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_cleaner-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Mabey
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-05-30 00:00:00.000000000 Z
12
+ date: 2021-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -85,16 +85,16 @@ dependencies:
85
85
  name: cucumber
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: '3.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: '3.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: activesupport
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -204,11 +204,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">"
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 1.3.1
209
+ version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.0.3
211
+ rubygems_version: 3.0.8
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Strategies for cleaning databases. Can be used to ensure a clean slate for