aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands/server_test.rb
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2012-03-20 19:28:30 -0400
committerschneems <richard.schneeman@gmail.com>2012-03-20 20:58:50 -0400
commit0a555dd421f3b7966df1a1f70ae462a143734d21 (patch)
tree37ab7eba1d1a23ab53215e942bb4ab3f54119607 /railties/test/commands/server_test.rb
parentb49a7ddce18a35a39fd5b3f6003d4a02cbd09b0e (diff)
downloadrails-0a555dd421f3b7966df1a1f70ae462a143734d21.tar.gz
rails-0a555dd421f3b7966df1a1f70ae462a143734d21.tar.bz2
rails-0a555dd421f3b7966df1a1f70ae462a143734d21.zip
fix rails server support of RAILS_ENV variable
When launching rails server from the command line with a rails environment specified such as `rails server RAILS_ENV=production` an error would occur since rails will try to use `RAILS_ENV=production` as it's server. When launching rails with a specified server such as thin `rails server thin RAILS_ENV=production` no error will be thrown, but rails will not start up in the specified environment. This fixes both of those cases
Diffstat (limited to 'railties/test/commands/server_test.rb')
-rw-r--r--railties/test/commands/server_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb
new file mode 100644
index 0000000000..8039aec873
--- /dev/null
+++ b/railties/test/commands/server_test.rb
@@ -0,0 +1,26 @@
+require 'abstract_unit'
+require 'rails/commands/server'
+
+class Rails::ServerTest < ActiveSupport::TestCase
+
+ def test_environment_with_server_option
+ args = ["thin", "RAILS_ENV=production"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal 'production', options[:environment]
+ assert_equal 'thin', options[:server]
+ end
+
+ def test_environment_without_server_option
+ args = ["RAILS_ENV=production"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal 'production', options[:environment]
+ assert_nil options[:server]
+ end
+
+ def test_server_option_without_environment
+ args = ["thin"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_nil options[:environment]
+ assert_equal 'thin', options[:server]
+ end
+end