From 8509829729648f6b87e4e6c3fa611799e18e8353 Mon Sep 17 00:00:00 2001 From: Ari Hiroki Date: Mon, 21 Nov 2016 04:10:34 +0900 Subject: [PATCH] fix access priorities of each level in LeveledOptions (#1118) Close #1103 --- lib/puma/configuration.rb | 2 +- test/test_config.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index 116ded2815..850d55f603 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -31,7 +31,7 @@ def shift end def [](key) - @set.each do |o| + @set.reverse_each do |o| if o.key? key return o[key] end diff --git a/test/test_config.rb b/test/test_config.rb index 11502baffb..bff985b4c9 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -57,6 +57,17 @@ def test_allow_users_to_override_default_options 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 + private def with_env(env = {})