提交 5e3ddf62 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #28513 from maclover7/jm-fix-28500

CLI arg "host" has precedence over ENV var "host"
......@@ -188,10 +188,12 @@ def port
end
def host
unless (default_host = options[:binding])
if options[:binding]
options[:binding]
else
default_host = environment == "development" ? "localhost" : "0.0.0.0"
ENV.fetch("HOST", default_host)
end
ENV.fetch("HOST", default_host)
end
def environment
......
......@@ -139,6 +139,14 @@ def test_host
end
end
def test_argument_precedence_over_environment_variable
switch_env "HOST", "1.2.3.4" do
args = ["-b", "127.0.0.1"]
options = parse_arguments(args)
assert_equal "127.0.0.1", options[:Host]
end
end
def test_records_user_supplied_options
server_options = parse_arguments(["-p", 3001])
assert_equal [:Port], server_options[:user_supplied_options]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册