Skip to content

Commit 92e5cf1

Browse files
committed
Normalizing the attribute hash names, fixing spec
1 parent db3eeb5 commit 92e5cf1

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

chef/lib/chef/node.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ def to_json(*a)
356356
result = {
357357
"name" => @name,
358358
'json_class' => self.class.name,
359-
"attributes" => @normal_attrs,
359+
"normal" => @normal_attrs,
360360
"chef_type" => "node",
361-
"defaults" => @default_attrs,
362-
"overrides" => @override_attrs,
361+
"default" => @default_attrs,
362+
"override" => @override_attrs,
363363
"run_list" => @run_list.run_list,
364364
}
365365
result["_rev"] = @couchdb_rev if @couchdb_rev
@@ -370,9 +370,12 @@ def to_json(*a)
370370
def self.json_create(o)
371371
node = new
372372
node.name(o["name"])
373-
node.normal_attrs = Mash.new(o["attributes"]) if o.has_key?("attributes")
374-
node.default_attrs = Mash.new(o["defaults"]) if o.has_key?("defaults")
375-
node.override_attrs = Mash.new(o["overrides"]) if o.has_key?("overrides")
373+
if o.has_key?("attributes")
374+
node.normal_attrs = o["attributes"]
375+
end
376+
node.normal_attrs = Mash.new(o["normal"]) if o.has_key?("normal")
377+
node.default_attrs = Mash.new(o["default"]) if o.has_key?("default")
378+
node.override_attrs = Mash.new(o["override"]) if o.has_key?("override")
376379

377380
if o.has_key?("run_list")
378381
node.run_list.reset!(o["run_list"])

chef/spec/unit/node_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@
344344
json = @node.to_json()
345345
json.should =~ /json_class/
346346
json.should =~ /name/
347-
json.should =~ /attributes/
348-
json.should =~ /overrides/
349-
json.should =~ /defaults/
347+
json.should =~ /normal/
348+
json.should =~ /default/
349+
json.should =~ /override/
350350
json.should =~ /run_list/
351351
end
352352

0 commit comments

Comments
 (0)