summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/mixin/deep_merge.rb2
-rw-r--r--spec/unit/node_spec.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb
index 7016b08ff7..9ec2b397d4 100644
--- a/lib/chef/mixin/deep_merge.rb
+++ b/lib/chef/mixin/deep_merge.rb
@@ -64,7 +64,7 @@ class Chef
when Hash
if dest.kind_of?(Hash)
source.each do |src_key, src_value|
- if dest[src_key]
+ if dest.key?(src_key)
dest[src_key] = deep_merge!(src_value, dest[src_key])
else # dest[src_key] doesn't exist so we take whatever source has
dest[src_key] = src_value
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 73f0e6da09..b6798b2de9 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -337,6 +337,13 @@ describe Chef::Node do
node.override_unless[:decontamination] = "foo"
expect(node.override[:decontamination]).to eql("foo")
end
+
+ it "consume_attributes does not exhibit chef/chef/issues/6302 bug" do
+ node.normal["a"]["r1"] = nil
+ node.consume_attributes({"a" => { "r2" => nil}})
+ expect(node["a"]["r1"]).to be_nil
+ expect(node["a"]["r2"]).to be_nil
+ end
end
describe "default attributes" do