Skip to content
This repository
Browse code

Force RAILS_ENV to be "test" when running tests, so that ENV["RAILS_E…

…NV"] = "production" in config/environment.rb doesnt wreck havok [DHH] (closes #2660)

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2955 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5c48a89a7f6f42391522a9ddaacee52a1843db5f 1 parent 6422f8b
David Heinemeier Hansson dhh authored
2  railties/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Force RAILS_ENV to be "test" when running tests, so that ENV["RAILS_ENV"] = "production" in config/environment.rb doesn't wreck havok [DHH] #2660
  4 +
3 5 * Correct versioning in :freeze_gems Rake task. #2778 [jakob@mentalized.net, Jeremy Kemper]
4 6
5 7 * Added an omnipresent RailsInfoController with a properties action that delivers an HTML rendering of Rails::Info (but only when local_request? is true). Added a new default index.html which fetches this with Ajax. [Sam Stephenson]
6 railties/environments/environment.rb
... ... @@ -1,8 +1,8 @@
1 1 # Be sure to restart your web server when you modify this file.
2 2
3   -# Uncomment below to force Rails into production mode
4   -# (Use only when you can't set environment variables through your web/app server)
5   -# ENV['RAILS_ENV'] ||= 'production' # Keep the ||=, don't use =, or tests will wipe production db
  3 +# Uncomment below to force Rails into production mode when
  4 +# you don't control web/app server and can't set it the proper way
  5 +# ENV['RAILS_ENV'] ||= 'production'
6 6
7 7 # Bootstrap the Rails environment, frameworks, and default configuration
8 8 require File.join(File.dirname(__FILE__), 'boot')
4 railties/lib/test_help.rb
... ... @@ -1,5 +1,9 @@
1 1 require 'application'
2 2
  3 +# Make double-sure the RAILS_ENV is set to test,
  4 +# so fixtures are loaded to the right database
  5 +silence_warnings { RAILS_ENV = "test" }
  6 +
3 7 require 'test/unit'
4 8 require 'active_record/fixtures'
5 9 require 'action_controller/test_process'

0 comments on commit 5c48a89

Please sign in to comment.
Something went wrong with that request. Please try again.