diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-01-03 23:37:37 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-01-03 23:37:37 -0500 |
commit | 50cb1b697c9409e28e5e515029d6292335a24a17 (patch) | |
tree | 9537b258eb33a536dedf5fbcd86128c1dfdb2964 | |
parent | a2b4df5b0bc2c1494665e07104cd2d8ceee08878 (diff) | |
parent | 498370c05b56ae02189466420da117b32304ddf9 (diff) | |
download | rails-50cb1b697c9409e28e5e515029d6292335a24a17.tar.gz rails-50cb1b697c9409e28e5e515029d6292335a24a17.tar.bz2 rails-50cb1b697c9409e28e5e515029d6292335a24a17.zip |
Merge pull request #27399 from sinogermany/rails-env-for-empty-string-env-vars
Rails env for empty string env vars
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rw-r--r-- | railties/lib/rails.rb | 3 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 12 |
3 files changed, 18 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 0276d84010..487f02d23f 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Make `Rails.env` fall back to `development` when `RAILS_ENV` and `RACK_ENV` is an empty string. + + *Daniel Deng* + * Remove deprecated `CONTROLLER` environment variable for `routes` task. *Rafael Mendonça França* diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index ee48043a50..00add5829d 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -7,6 +7,7 @@ require "active_support/dependencies/autoload" require "active_support/core_ext/kernel/reporting" require "active_support/core_ext/module/delegation" require "active_support/core_ext/array/extract_options" +require "active_support/core_ext/object/blank" require "rails/application" require "rails/version" @@ -67,7 +68,7 @@ module Rails # Rails.env.development? # => true # Rails.env.production? # => false def env - @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development") + @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development") end # Sets the Rails environment. diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 6ed6f0b312..01a9807b6b 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -78,6 +78,18 @@ module ApplicationTests end end + test "Rails.env falls back to development if RAILS_ENV is blank and RACK_ENV is nil" do + with_rails_env("") do + assert_equal "development", Rails.env + end + end + + test "Rails.env falls back to development if RACK_ENV is blank and RAILS_ENV is nil" do + with_rack_env("") do + assert_equal "development", Rails.env + end + end + test "By default logs tags are not set in development" do restore_default_config |