Skip to content

Commit

Permalink
Merge branch 'master' into allowlist-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
etagwerker committed Oct 9, 2020
2 parents 089f8dc + 661fe7e commit e4a1fe7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions lib/database_cleaner/cleaners.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def initialize hash={}
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)
Expand Down Expand Up @@ -37,8 +37,8 @@ def clean_with(*args)

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
Expand Down
2 changes: 1 addition & 1 deletion lib/database_cleaner/safeguard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def skip?
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?
Expand Down
2 changes: 1 addition & 1 deletion spec/database_cleaner/safeguard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }

Expand Down

0 comments on commit e4a1fe7

Please sign in to comment.