Merge branch 'master' into allowlist-regex

This commit is contained in:
Ernesto Tagwerker 2020-10-09 11:42:57 -04:00 committed by GitHub
commit e4a1fe7683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 8 deletions

View File

@ -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`

View File

@ -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.

View File

@ -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

View File

@ -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?

View File

@ -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") }