Skip to content

Commit

Permalink
Correctly shows RAILS_ENV=development even when ENV['RAILS_ENV'] is n…
Browse files Browse the repository at this point in the history
…ot set (e.g., in Pow)

* Fixes rails#8025
  • Loading branch information
alindeman committed Dec 21, 2012
1 parent 33b3fa6 commit 6b692ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/migration.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(name)


class PendingMigrationError < ActiveRecordError#:nodoc: class PendingMigrationError < ActiveRecordError#:nodoc:
def initialize 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
end end


Expand Down
12 changes: 12 additions & 0 deletions railties/test/application/configuration_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
require "isolation/abstract_unit" require "isolation/abstract_unit"
require 'rack/test' require 'rack/test'
require 'env_helpers'


class ::MyMailInterceptor class ::MyMailInterceptor
def self.delivering_email(email); email; end def self.delivering_email(email); email; end
Expand All @@ -17,6 +18,7 @@ module ApplicationTests
class ConfigurationTest < ActiveSupport::TestCase class ConfigurationTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation include ActiveSupport::Testing::Isolation
include Rack::Test::Methods include Rack::Test::Methods
include EnvHelpers


def new_app def new_app
File.expand_path("#{app_path}/../new_app") File.expand_path("#{app_path}/../new_app")
Expand All @@ -41,6 +43,16 @@ def teardown
FileUtils.rm_rf(new_app) if File.directory?(new_app) FileUtils.rm_rf(new_app) if File.directory?(new_app)
end 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 test "a renders exception on pending migration" do
add_to_config <<-RUBY add_to_config <<-RUBY
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
Expand Down

0 comments on commit 6b692ee

Please sign in to comment.