Merge pull request #27399 from sinogermany/rails-env-for-empty-string-env-vars
Rails env for empty string env vars
This commit is contained in:
commit
50cb1b697c
@ -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*
|
||||
|
@ -7,6 +7,7 @@
|
||||
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 @@ def root
|
||||
# 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.
|
||||
|
@ -78,6 +78,18 @@ def restore_default_config
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user