From d578cbfb5c9fa353ce041bc826e13905910e2d2a Mon Sep 17 00:00:00 2001 From: Damien Mathieu Date: Thu, 19 Mar 2015 10:06:28 +0100 Subject: don't fallback to RACK_ENV when RAILS_ENV is not present --- railties/test/application/rake/dbs_test.rb | 3 -- railties/test/application/runner_test.rb | 6 --- railties/test/commands/console_test.rb | 7 ---- railties/test/commands/dbconsole_test.rb | 5 --- railties/test/commands/server_test.rb | 63 +++++++++--------------------- railties/test/env_helpers.rb | 9 ----- 6 files changed, 19 insertions(+), 74 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index c414732f92..1da108f1e1 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -203,9 +203,7 @@ module ApplicationTests test 'db:setup loads schema and seeds database' do begin @old_rails_env = ENV["RAILS_ENV"] - @old_rack_env = ENV["RACK_ENV"] ENV.delete "RAILS_ENV" - ENV.delete "RACK_ENV" app_file 'db/schema.rb', <<-RUBY ActiveRecord::Schema.define(version: "1") do @@ -225,7 +223,6 @@ module ApplicationTests end ensure ENV["RAILS_ENV"] = @old_rails_env - ENV["RACK_ENV"] = @old_rack_env end end end diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 6595c40f8b..b59202e68e 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -79,11 +79,5 @@ module ApplicationTests assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } end end - - def test_environment_with_rack_env - with_rack_env "production" do - assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } - end - end end end diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb index de0cf0ba9e..d7614de9e3 100644 --- a/railties/test/commands/console_test.rb +++ b/railties/test/commands/console_test.rb @@ -70,13 +70,6 @@ class Rails::ConsoleTest < ActiveSupport::TestCase end end - def test_default_environment_with_rack_env - with_rack_env 'production' do - start - assert_match(/\sproduction\s/, output) - end - end - def test_e_option start ['-e', 'special-production'] assert_match(/\sspecial-production\s/, output) diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index a3cd1eb0ed..b8c7354ed0 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -82,20 +82,15 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase assert_equal "test", Rails::DBConsole.new.environment ENV['RAILS_ENV'] = nil - ENV['RACK_ENV'] = nil Rails.stub(:respond_to?, false) do assert_equal "development", Rails::DBConsole.new.environment - ENV['RACK_ENV'] = "rack_env" - assert_equal "rack_env", Rails::DBConsole.new.environment - ENV['RAILS_ENV'] = "rails_env" assert_equal "rails_env", Rails::DBConsole.new.environment end ensure ENV['RAILS_ENV'] = "test" - ENV['RACK_ENV'] = nil end def test_rails_env_is_development_when_argument_is_dev diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb index ba688f1e9e..8427ac1bc2 100644 --- a/railties/test/commands/server_test.rb +++ b/railties/test/commands/server_test.rb @@ -27,61 +27,36 @@ class Rails::ServerTest < ActiveSupport::TestCase end def test_environment_with_rails_env - with_rack_env nil do - with_rails_env 'production' do - server = Rails::Server.new - assert_equal 'production', server.options[:environment] - end + with_rails_env 'production' do + server = Rails::Server.new + assert_equal 'production', server.options[:environment] end end - def test_environment_with_rack_env + def test_log_stdout with_rails_env nil do - with_rack_env 'production' do - server = Rails::Server.new - assert_equal 'production', server.options[:environment] - end - end - end + args = [] + options = Rails::Server::Options.new.parse!(args) + assert_equal true, options[:log_stdout] - def test_log_stdout - with_rack_env nil do - with_rails_env nil do - args = [] - options = Rails::Server::Options.new.parse!(args) - assert_equal true, options[:log_stdout] + args = ["-e", "development"] + options = Rails::Server::Options.new.parse!(args) + assert_equal true, options[:log_stdout] - args = ["-e", "development"] + args = ["-e", "production"] + options = Rails::Server::Options.new.parse!(args) + assert_equal false, options[:log_stdout] + + with_rails_env 'development' do + args = [] options = Rails::Server::Options.new.parse!(args) assert_equal true, options[:log_stdout] + end - args = ["-e", "production"] + with_rails_env 'production' do + args = [] options = Rails::Server::Options.new.parse!(args) assert_equal false, options[:log_stdout] - - with_rack_env 'development' do - args = [] - options = Rails::Server::Options.new.parse!(args) - assert_equal true, options[:log_stdout] - end - - with_rack_env 'production' do - args = [] - options = Rails::Server::Options.new.parse!(args) - assert_equal false, options[:log_stdout] - end - - with_rails_env 'development' do - args = [] - options = Rails::Server::Options.new.parse!(args) - assert_equal true, options[:log_stdout] - end - - with_rails_env 'production' do - args = [] - options = Rails::Server::Options.new.parse!(args) - assert_equal false, options[:log_stdout] - end end end end diff --git a/railties/test/env_helpers.rb b/railties/test/env_helpers.rb index 330fe150ca..fea06e528f 100644 --- a/railties/test/env_helpers.rb +++ b/railties/test/env_helpers.rb @@ -12,15 +12,6 @@ module EnvHelpers end end - def with_rack_env(env) - Rails.instance_variable_set :@_env, nil - switch_env 'RACK_ENV', env do - switch_env 'RAILS_ENV', nil do - yield - end - end - end - def switch_env(key, value) old, ENV[key] = ENV[key], value yield -- cgit v1.2.3