diff --git a/History.rdoc b/History.rdoc index 80da1ba..7f89d06 100644 --- a/History.rdoc +++ b/History.rdoc @@ -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` diff --git a/README.markdown b/README.markdown index 3e18fc3..b1d89fb 100644 --- a/README.markdown +++ b/README.markdown @@ -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. diff --git a/lib/database_cleaner/cleaners.rb b/lib/database_cleaner/cleaners.rb index 506ca35..20cbf5f 100644 --- a/lib/database_cleaner/cleaners.rb +++ b/lib/database_cleaner/cleaners.rb @@ -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 diff --git a/lib/database_cleaner/safeguard.rb b/lib/database_cleaner/safeguard.rb index 91197ca..353d0a7 100644 --- a/lib/database_cleaner/safeguard.rb +++ b/lib/database_cleaner/safeguard.rb @@ -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? diff --git a/spec/database_cleaner/safeguard_spec.rb b/spec/database_cleaner/safeguard_spec.rb index 89d8656..c933c0e 100644 --- a/spec/database_cleaner/safeguard_spec.rb +++ b/spec/database_cleaner/safeguard_spec.rb @@ -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") }