Skip to content

Commit 40a3d55

Browse files
committed
Fixing the keys method to include auto_attrs
1 parent 2b78636 commit 40a3d55

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

chef/lib/chef/node.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ def each_attribute(&block)
300300
def method_missing(symbol, *args)
301301
attrs = Chef::Node::Attribute.new(@normal_attrs, @default_attrs, @override_attrs, @automatic_attrs)
302302
attrs.set_type = :normal
303-
attrs.auto_vivify_on_read = true
304303
attrs.send(symbol, *args)
305304
end
306305

chef/lib/chef/node/attribute.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,12 @@ def get_keys
236236
end
237237

238238
def keys
239-
tkeys = []
240-
if current_override
241-
tkeys = current_override.keys
242-
end
243-
if current_normal
244-
current_normal.keys.each do |key|
245-
tkeys << key unless tkeys.include?(key)
246-
end
247-
end
248-
if current_default
249-
current_default.keys.each do |key|
250-
tkeys << key unless tkeys.include?(key)
239+
tkeys = current_automatic ? current_automatic.keys : []
240+
[ current_override, current_normal, current_default ].each do |attr_hash|
241+
if attr_hash
242+
attr_hash.keys.each do |key|
243+
tkeys << key unless tkeys.include?(key)
244+
end
251245
end
252246
end
253247
tkeys

chef/spec/unit/client_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
:hostname => "foo"
128128
}
129129
@mock_ohai.stub!(:refresh_plugins).and_return(true)
130+
@mock_ohai.stub!(:data).and_return(@mock_ohai)
130131
Ohai::System.stub!(:new).and_return(@mock_ohai)
131132
@node = Chef::Node.new
132133
@mock_rest.stub!(:get_rest).and_return(@node)

0 commit comments

Comments
 (0)