mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge branch 'twalpole-parameter_overwrite'
This commit is contained in:
commit
6b96a9398f
3 changed files with 32 additions and 2 deletions
|
@ -30,8 +30,13 @@ module Puma
|
|||
@set << @cur
|
||||
end
|
||||
|
||||
def reverse_shift
|
||||
@cur = {}
|
||||
@set.unshift(@cur)
|
||||
end
|
||||
|
||||
def [](key)
|
||||
@set.each do |o|
|
||||
@set.reverse_each do |o|
|
||||
if o.key? key
|
||||
return o[key]
|
||||
end
|
||||
|
@ -201,10 +206,11 @@ module Puma
|
|||
end
|
||||
|
||||
files.each do |f|
|
||||
@options.shift
|
||||
@options.reverse_shift
|
||||
|
||||
DSL.load @options, self, f
|
||||
end
|
||||
@options.shift
|
||||
end
|
||||
|
||||
# Call once all configuration (included from rackup files)
|
||||
|
|
2
test/config/settings.rb
Normal file
2
test/config/settings.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
port 3000
|
||||
threads 3, 5
|
|
@ -56,6 +56,28 @@ class TestConfigFile < Minitest::Test
|
|||
assert_equal 'bin/rails server', conf.options[:restart_cmd]
|
||||
end
|
||||
|
||||
def test_overwrite_options
|
||||
conf = Puma::Configuration.new do |c|
|
||||
c.workers 3
|
||||
end
|
||||
conf.load
|
||||
|
||||
assert_equal conf.options[:workers], 3
|
||||
conf.options[:workers] += 1
|
||||
assert_equal conf.options[:workers], 4
|
||||
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
|
||||
|
||||
def with_env(env = {})
|
||||
|
|
Loading…
Add table
Reference in a new issue