fix: prevent Config DEFAULTS mutation through deep_merge
Freeze inner hashes in DEFAULTS and rewrite deep_merge to build fresh
hashes with {}.merge for uncopied inner maps. Previously, inner hashes
shared objects with the frozen-looking DEFAULTS, so mutating a loaded
config silently poisoned all later loads.
This commit is contained in:
@@ -27,6 +27,14 @@ class ConfigTest < Minitest::Test
|
||||
assert_equal "0.0.0.0", Volumen::Config.load(path: MISSING).host
|
||||
end
|
||||
|
||||
def test_does_not_mutate_default_inner_hashes
|
||||
config = Volumen::Config.load(path: MISSING)
|
||||
config.site["title"] = "MUTATED"
|
||||
fresh = Volumen::Config.load(path: MISSING)
|
||||
assert_equal "My Blog", fresh.site["title"],
|
||||
"mutating a loaded config must not poison DEFAULTS for later loads"
|
||||
end
|
||||
|
||||
def test_loads_and_merges_file
|
||||
Dir.mktmpdir do |dir|
|
||||
path = File.join(dir, "config.toml")
|
||||
|
||||
Reference in New Issue
Block a user