From 6f3259bc4272bc43d8cbbfc6af7edf9049922802 Mon Sep 17 00:00:00 2001 From: Joel Van Horn Date: Thu, 9 Jul 2020 13:45:44 -0400 Subject: [PATCH 1/3] Add APP_ENV --- lib/database_cleaner/safeguard.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/database_cleaner/safeguard.rb b/lib/database_cleaner/safeguard.rb index 5ca2703..fa1cb0e 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? From 12c904161a55a481f44881e92b4b3dee88abe5d4 Mon Sep 17 00:00:00 2001 From: Joel Van Horn Date: Thu, 9 Jul 2020 13:47:06 -0400 Subject: [PATCH 2/3] Add APP_ENV --- spec/database_cleaner/safeguard_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/database_cleaner/safeguard_spec.rb b/spec/database_cleaner/safeguard_spec.rb index 573ae2c..d757223 100644 --- a/spec/database_cleaner/safeguard_spec.rb +++ b/spec/database_cleaner/safeguard_spec.rb @@ -126,7 +126,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") } From 9bc66d6c7e442b8481d63301d420ae4057627c50 Mon Sep 17 00:00:00 2001 From: Joel Van Horn Date: Thu, 9 Jul 2020 13:47:41 -0400 Subject: [PATCH 3/3] Add APP_ENV --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2d933fa..09466b1 100644 --- a/README.markdown +++ b/README.markdown @@ -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.