Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Puma::StateFile#load incompatibility #2810

Merged
merged 3 commits into from Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/puma/state_file.rb
Expand Up @@ -50,6 +50,7 @@ def load(path)
v = v.strip
@options[k] =
case v
when '' then nil
when /\A\d+\z/ then v.to_i
when /\A\d+\.\d+\z/ then v.to_f
else v.gsub(/\A"|"\z/, '')
Expand Down
27 changes: 27 additions & 0 deletions test/test_state_file.rb
@@ -0,0 +1,27 @@
require_relative "helper"
require_relative "helpers/tmp_path"

require 'puma/state_file'

class TestStateFile < Minitest::Test
include TmpPath

def test_load_empty_value_as_nil
state_path = tmp_path('.state')
File.write state_path, <<-STATE
---
pid: 123456
control_url:
control_auth_token:
running_from: "/path/to/app"
STATE

sf = Puma::StateFile.new
sf.load(state_path)
assert_equal 123456, sf.pid
assert_equal '/path/to/app', sf.running_from
assert_nil sf.control_url
assert_nil sf.control_auth_token

end
end