1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Use config file before default port with handler

This commit is contained in:
schneems 2017-03-03 13:20:59 -08:00
parent cda9317e71
commit 24f12579bf
2 changed files with 21 additions and 19 deletions

View file

@ -40,10 +40,14 @@ module Rack
uri.port ||= options[:Port] || ::Puma::Configuration::DefaultTCPPort
user_config.bind uri.to_s
else
host ||= ::Puma::Configuration::DefaultTCPHost
port = options[:Port] || ::Puma::Configuration::DefaultTCPPort
if host
options[:Port] ||= ::Puma::Configuration::DefaultTCPPort
end
user_config.port port, host
if port = options[:Port]
host ||= ::Puma::Configuration::DefaultTCPHost
user_config.port port, host
end
end
user_config.app app

View file

@ -73,23 +73,21 @@ class TestPathHandler < Minitest::Test
# end
# end
# def test_default_port_loses_to_config_file
# user_port = 5001
# file_port = 6001
# options = {}
def test_default_port_loses_to_config_file
user_port = 5001
file_port = 6001
options = {}
# Tempfile.open("puma.rb") do |f|
# f.puts "port #{file_port}"
# f.close
Dir.mktmpdir do |d|
Dir.chdir(d) do
FileUtils.mkdir("config")
File.open("config/puma.rb", "w") { |f| f << "port #{6001}" }
# options[:config_files] = [f.path]
# options[:user_supplied_options] = []
# options[:Port] = user_port
conf = Rack::Handler::Puma.config(app, options)
conf.load
# conf = Rack::Handler::Puma.config(app, options)
# conf.load
# puts conf.options[:binds]
# assert_equal ["tcp://0.0.0.0:#{file_port}"], conf.options[:binds]
# end
# end
assert_equal ["tcp://0.0.0.0:#{file_port}"], conf.options[:binds]
end
end
end
end