aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2012-12-06 02:05:33 +0900
committerkennyj <kennyj@gmail.com>2012-12-06 02:05:33 +0900
commita7695579a5979245f7d5e683a67bbfc096f3099a (patch)
tree07955176072c0881e71dfc782fbb3d730560a262 /railties/test/commands
parent396c0681acab95a58f0583d722f488b5b01398d8 (diff)
downloadrails-a7695579a5979245f7d5e683a67bbfc096f3099a.tar.gz
rails-a7695579a5979245f7d5e683a67bbfc096f3099a.tar.bz2
rails-a7695579a5979245f7d5e683a67bbfc096f3099a.zip
Add ENV['RACK_ENV'] support to rake runner/console/server.
Diffstat (limited to 'railties/test/commands')
-rw-r--r--railties/test/commands/console_test.rb19
-rw-r--r--railties/test/commands/server_test.rb20
2 files changed, 37 insertions, 2 deletions
diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb
index f99ea13022..4062905c16 100644
--- a/railties/test/commands/console_test.rb
+++ b/railties/test/commands/console_test.rb
@@ -78,6 +78,13 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
assert_match(/\sspecial-production\s/, output)
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']
@@ -128,10 +135,18 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
end
def with_rails_env(env)
- original_rails_env = ENV['RAILS_ENV']
+ rails = ENV['RAILS_ENV']
ENV['RAILS_ENV'] = env
yield
ensure
- ENV['RAILS_ENV'] = original_rails_env
+ ENV['RAILS_ENV'] = rails
+ end
+
+ def with_rack_env(env)
+ rack = ENV['RACK_ENV']
+ ENV['RACK_ENV'] = env
+ with_rails_env(nil) { yield }
+ ensure
+ ENV['RACK_ENV'] = rack
end
end
diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb
index 4a3ea82e3d..6a75207ebb 100644
--- a/railties/test/commands/server_test.rb
+++ b/railties/test/commands/server_test.rb
@@ -23,4 +23,24 @@ class Rails::ServerTest < ActiveSupport::TestCase
assert_nil options[:environment]
assert_equal 'thin', options[:server]
end
+
+ def test_environment_with_rails_env
+ rails = ENV['RAILS_ENV']
+ ENV['RAILS_ENV'] = 'production'
+ server = Rails::Server.new
+ assert_equal 'production', server.options[:environment]
+ ensure
+ ENV['RAILS_ENV'] = rails
+ end
+
+ def test_environment_with_rack_env
+ rack, rails = ENV['RACK_ENV'], ENV['RAILS_ENV']
+ ENV['RAILS_ENV'] = nil
+ ENV['RACK_ENV'] = 'production'
+ server = Rails::Server.new
+ assert_equal 'production', server.options[:environment]
+ ensure
+ ENV['RACK_ENV'] = rack
+ ENV['RAILS_ENV'] = rails
+ end
end