mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Correctly shows RAILS_ENV=development even when ENV['RAILS_ENV'] is not set (e.g., in Pow)
* Fixes #8025
This commit is contained in:
parent
33b3fa67c4
commit
6b692ee37c
2 changed files with 13 additions and 1 deletions
|
@ -32,7 +32,7 @@ module ActiveRecord
|
|||
|
||||
class PendingMigrationError < ActiveRecordError#:nodoc:
|
||||
def initialize
|
||||
super("Migrations are pending; run 'rake db:migrate RAILS_ENV=#{ENV['RAILS_ENV']}' to resolve this issue.")
|
||||
super("Migrations are pending; run 'rake db:migrate RAILS_ENV=#{Rails.env}' to resolve this issue.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require "isolation/abstract_unit"
|
||||
require 'rack/test'
|
||||
require 'env_helpers'
|
||||
|
||||
class ::MyMailInterceptor
|
||||
def self.delivering_email(email); email; end
|
||||
|
@ -17,6 +18,7 @@ module ApplicationTests
|
|||
class ConfigurationTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Isolation
|
||||
include Rack::Test::Methods
|
||||
include EnvHelpers
|
||||
|
||||
def new_app
|
||||
File.expand_path("#{app_path}/../new_app")
|
||||
|
@ -41,6 +43,16 @@ module ApplicationTests
|
|||
FileUtils.rm_rf(new_app) if File.directory?(new_app)
|
||||
end
|
||||
|
||||
test "Rails.env does not set the RAILS_ENV environment variable which would leak out into rake tasks" do
|
||||
require "rails"
|
||||
|
||||
switch_env "RAILS_ENV", nil do
|
||||
Rails.env = "development"
|
||||
assert_equal "development", Rails.env
|
||||
assert_nil ENV['RAILS_ENV']
|
||||
end
|
||||
end
|
||||
|
||||
test "a renders exception on pending migration" do
|
||||
add_to_config <<-RUBY
|
||||
config.active_record.migration_error = :page_load
|
||||
|
|
Loading…
Reference in a new issue