diff options
-rw-r--r-- | railties/lib/rails.rb | 4 | ||||
-rw-r--r-- | railties/test/railties/railtie_test.rb | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index 9d02da104d..085b82c154 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -79,6 +79,10 @@ module Rails @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development") end + def env=(environment) + @_env = ActiveSupport::StringInquirer.new(environment) + end + def cache RAILS_CACHE end diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb index 546bf5e143..2accaca855 100644 --- a/railties/test/railties/railtie_test.rb +++ b/railties/test/railties/railtie_test.rb @@ -125,5 +125,16 @@ module RailtiesTest require "#{app_path}/config/environment" assert $ran_block end + + test "we can change our environment if we want to" do + begin + original_env = Rails.env + Rails.env = 'foo' + assert_equal('foo', Rails.env) + ensure + Rails.env = original_env + assert_equal(original_env, Rails.env) + end + end end end |