Merge branch 'master' into allowlist-regex
This commit is contained in:
commit
e4a1fe7683
|
@ -3,6 +3,7 @@
|
|||
=== Changes
|
||||
* Rename `url_whitelist` to `url_allowlist`
|
||||
* Allowlist now supports regular expressions
|
||||
* Fixed Ruby 2.7 deprecation warnings
|
||||
|
||||
=== Breaking changes
|
||||
* Failed checks against the allowlist now raise `UrlNotAllowed` rather than `NotWhitelistedUrl`
|
||||
|
|
|
@ -137,7 +137,7 @@ So what is fastest out of `:deletion` and `:truncation`? Well, it depends on you
|
|||
|
||||
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.
|
||||
|
||||
If you are using ActiveRecord then take a look at the [additional options](#additional-activerecord-options-for-truncation) available for `:truncation`.
|
||||
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`.
|
||||
|
||||
Database Cleaner also includes a `null` strategy (that does no cleaning at all) which can be used with any ORM library.
|
||||
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
|
|||
|
||||
DatabaseCleaner comes with safeguards against:
|
||||
|
||||
* Running in production (checking for `ENV`, `RACK_ENV`, and `RAILS_ENV`)
|
||||
* Running in production (checking for `ENV`, `APP_ENV`, `RACK_ENV`, and `RAILS_ENV`)
|
||||
* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`, `.local` or `127.0.0.1`)
|
||||
|
||||
Both safeguards can be disabled separately as follows.
|
||||
|
|
|
@ -7,9 +7,9 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
# FIXME this method conflates creation with lookup... both a command and a query. yuck.
|
||||
def [](orm, opts = {})
|
||||
def [](orm, **opts)
|
||||
raise ArgumentError if orm.nil?
|
||||
fetch([orm, opts]) { add_cleaner(orm, opts) }
|
||||
fetch([orm, opts]) { add_cleaner(orm, **opts) }
|
||||
end
|
||||
|
||||
def strategy=(strategy)
|
||||
|
@ -37,8 +37,8 @@ module DatabaseCleaner
|
|||
|
||||
private
|
||||
|
||||
def add_cleaner(orm, opts = {})
|
||||
self[[orm, opts]] = Cleaner.new(orm, opts)
|
||||
def add_cleaner(orm, **opts)
|
||||
self[[orm, opts]] = Cleaner.new(orm, **opts)
|
||||
end
|
||||
|
||||
def remove_duplicates
|
||||
|
|
|
@ -72,7 +72,7 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
class Production
|
||||
KEYS = %w(ENV RACK_ENV RAILS_ENV)
|
||||
KEYS = %w(ENV APP_ENV RACK_ENV RAILS_ENV)
|
||||
|
||||
def run
|
||||
raise Error::ProductionEnv.new(key) if !skip? && given?
|
||||
|
|
|
@ -157,7 +157,7 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
describe 'ENV is set to production' do
|
||||
%w(ENV RACK_ENV RAILS_ENV).each do |key|
|
||||
%w(ENV APP_ENV RACK_ENV RAILS_ENV).each do |key|
|
||||
describe "on #{key}" do
|
||||
before { stub_const('ENV', key => "production") }
|
||||
|
||||
|
|
Loading…
Reference in New Issue