mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
0a555dd421
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
26 lines
794 B
Ruby
26 lines
794 B
Ruby
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
|