diff options
author | Damien Mathieu <damien@heroku.com> | 2015-03-19 10:06:28 +0100 |
---|---|---|
committer | Damien Mathieu <damien@heroku.com> | 2015-03-19 10:06:28 +0100 |
commit | d578cbfb5c9fa353ce041bc826e13905910e2d2a (patch) | |
tree | 825cabca0569e490290923ea8cb0c6f0a86eef2f /activerecord | |
parent | 7f338b9082fe3488f681c171b93c371cfc951f22 (diff) | |
download | rails-d578cbfb5c9fa353ce041bc826e13905910e2d2a.tar.gz rails-d578cbfb5c9fa353ce041bc826e13905910e2d2a.tar.bz2 rails-d578cbfb5c9fa353ce041bc826e13905910e2d2a.zip |
don't fallback to RACK_ENV when RAILS_ENV is not present
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_handling.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb | 34 |
2 files changed, 1 insertions, 35 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 24f5849e45..d0deb7751c 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -1,6 +1,6 @@ module ActiveRecord module ConnectionHandling - RAILS_ENV = -> { (Rails.env if defined?(Rails.env)) || ENV["RAILS_ENV"] || ENV["RACK_ENV"] } + RAILS_ENV = -> { (Rails.env if defined?(Rails.env)) || ENV["RAILS_ENV"] } DEFAULT_ENV = -> { RAILS_ENV.call || "default_env" } # Establishes the connection to the database. Accepts a hash as input where diff --git a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb index 9ee92a3cd2..9756a2b891 100644 --- a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +++ b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb @@ -5,13 +5,11 @@ module ActiveRecord class MergeAndResolveDefaultUrlConfigTest < ActiveRecord::TestCase def setup @previous_database_url = ENV.delete("DATABASE_URL") - @previous_rack_env = ENV.delete("RACK_ENV") @previous_rails_env = ENV.delete("RAILS_ENV") end teardown do ENV["DATABASE_URL"] = @previous_database_url - ENV["RACK_ENV"] = @previous_rack_env ENV["RAILS_ENV"] = @previous_rails_env end @@ -41,16 +39,6 @@ module ActiveRecord assert_equal expected, actual end - def test_resolver_with_database_uri_and_current_env_symbol_key_and_rack_env - ENV['DATABASE_URL'] = "postgres://localhost/foo" - ENV['RACK_ENV'] = "foo" - - config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } } - actual = resolve_spec(:foo, config) - expected = { "adapter" => "postgresql", "database" => "foo", "host" => "localhost" } - assert_equal expected, actual - end - def test_resolver_with_database_uri_and_known_key ENV['DATABASE_URL'] = "postgres://localhost/foo" config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } } @@ -173,28 +161,6 @@ module ActiveRecord assert_equal nil, actual[:test] end - def test_blank_with_database_url_with_rack_env - ENV['RACK_ENV'] = "not_production" - ENV['DATABASE_URL'] = "postgres://localhost/foo" - - config = {} - actual = resolve_config(config) - expected = { "adapter" => "postgresql", - "database" => "foo", - "host" => "localhost" } - - assert_equal expected, actual["not_production"] - assert_equal nil, actual["production"] - assert_equal nil, actual["default_env"] - assert_equal nil, actual["development"] - assert_equal nil, actual["test"] - assert_equal nil, actual[:default_env] - assert_equal nil, actual[:not_production] - assert_equal nil, actual[:production] - assert_equal nil, actual[:development] - assert_equal nil, actual[:test] - end - def test_database_url_with_ipv6_host_and_port ENV['DATABASE_URL'] = "postgres://[::1]:5454/foo" |