diff options
author | danielsdeleo <dan@chef.io> | 2015-09-14 19:15:41 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2015-09-16 16:44:16 -0700 |
commit | c477e5c966e037cd9420b0c153cb7590e656a0b4 (patch) | |
tree | 369922a63b9eedda739be98ccebb0434b30053c8 | |
parent | ec46251216f37ff3d5d8312f06a8ba63452db47e (diff) | |
download | chef-c477e5c966e037cd9420b0c153cb7590e656a0b4.tar.gz |
Populate node policyfile attrs from JSON
-rw-r--r-- | lib/chef/node.rb | 4 | ||||
-rw-r--r-- | spec/unit/node_spec.rb | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 3c3286c548..668ddbdc35 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -549,6 +549,10 @@ class Chef else o["recipes"].each { |r| node.recipes << r } end + + node.policy_name = o["policy_name"] if o.has_key?("policy_name") + node.policy_group = o["policy_group"] if o.has_key?("policy_group") + node end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 91177233a8..5f3bed2833 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -1212,6 +1212,14 @@ describe Chef::Node do expect(node.for_json).to have_key("policy_group") expect(node.for_json["policy_group"]).to eq("staging") end + + it "parses policyfile attributes from JSON" do + round_tripped_node = Chef::Node.json_create(node.for_json) + + expect(round_tripped_node.policy_name).to eq("my-application") + expect(round_tripped_node.policy_group).to eq("staging") + end + end include_examples "to_json equivalent to Chef::JSONCompat.to_json" do |