diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-03-19 07:46:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-03-19 07:46:57 -0700 |
commit | 7bdc7635b885e473f6a577264fd8efad1c02174f (patch) | |
tree | d5a1331c223888514488113dfbb2358229422921 /railties/test | |
parent | 45786be516e13d55a1fca9a4abaddd5781209103 (diff) | |
parent | d578cbfb5c9fa353ce041bc826e13905910e2d2a (diff) | |
download | rails-7bdc7635b885e473f6a577264fd8efad1c02174f.tar.gz rails-7bdc7635b885e473f6a577264fd8efad1c02174f.tar.bz2 rails-7bdc7635b885e473f6a577264fd8efad1c02174f.zip |
Merge pull request #19404 from dmathieu/remove_rack_env
Don't fallback to RACK_ENV when RAILS_ENV is not present
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 3 | ||||
-rw-r--r-- | railties/test/application/runner_test.rb | 6 | ||||
-rw-r--r-- | railties/test/commands/console_test.rb | 7 | ||||
-rw-r--r-- | railties/test/commands/dbconsole_test.rb | 5 | ||||
-rw-r--r-- | railties/test/commands/server_test.rb | 63 | ||||
-rw-r--r-- | railties/test/env_helpers.rb | 9 |
6 files changed, 19 insertions, 74 deletions
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 |