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

Specified parameters should overwrite loaded config files

This commit is contained in:
Thomas Walpole 2017-01-30 20:29:19 -08:00
parent 42126a23d4
commit 5f24229fbc
3 changed files with 20 additions and 1 deletions

View file

@ -30,6 +30,11 @@ module Puma
@set << @cur @set << @cur
end end
def reverse_shift
@cur = {}
@set.unshift(@cur)
end
def [](key) def [](key)
@set.reverse_each do |o| @set.reverse_each do |o|
if o.key? key if o.key? key
@ -201,10 +206,11 @@ module Puma
end end
files.each do |f| files.each do |f|
@options.shift @options.reverse_shift
DSL.load @options, self, f DSL.load @options, self, f
end end
@options.shift
end end
# Call once all configuration (included from rackup files) # Call once all configuration (included from rackup files)

2
test/config/settings.rb Normal file
View file

@ -0,0 +1,2 @@
port 3000
threads 3, 5

View file

@ -67,6 +67,17 @@ class TestConfigFile < Minitest::Test
assert_equal conf.options[:workers], 4 assert_equal conf.options[:workers], 4
end end
def test_parameters_overwrite_files
conf = Puma::Configuration.new(config_files: ['test/config/settings.rb']) do |c|
c.port 3030
end
conf.load
assert_match(/:3030$/, conf.options[:binds].first)
assert_equal 3, conf.options[:min_threads]
assert_equal 5, conf.options[:max_threads]
end
private private
def with_env(env = {}) def with_env(env = {})