diff options
author | Andy Lindeman <alindeman@gmail.com> | 2012-12-20 17:41:52 -0500 |
---|---|---|
committer | Andy Lindeman <alindeman@gmail.com> | 2012-12-21 17:41:39 -0500 |
commit | 6b692ee37c08f1abee8c9b8a12f9b7f1234afb00 (patch) | |
tree | 484676c70293c6ed7aa071b383593d035a43a190 | |
parent | 33b3fa67c49715c98b37c737ec83937168aad859 (diff) | |
download | rails-6b692ee37c08f1abee8c9b8a12f9b7f1234afb00.tar.gz rails-6b692ee37c08f1abee8c9b8a12f9b7f1234afb00.tar.bz2 rails-6b692ee37c08f1abee8c9b8a12f9b7f1234afb00.zip |
Correctly shows RAILS_ENV=development even when ENV['RAILS_ENV'] is not set (e.g., in Pow)
* Fixes #8025
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 806b367c6b..273af32237 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -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 diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index ae1127b509..53109cb041 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -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 |