summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-10-21 11:13:37 -0700
committerSerdar Sutay <serdar@opscode.com>2014-10-21 11:13:37 -0700
commitccb220a72ba07a9b2cbabba25f88edb7e7064d7b (patch)
treef29e9c4e35f923910978c9acb293d4bda299a30d
parentadfaf6ce192a4520716ce3827d33c7110221bff9 (diff)
parentdd3a00dcb983f895038c86c0dd638638e0f7e56e (diff)
downloadchef-ccb220a72ba07a9b2cbabba25f88edb7e7064d7b.tar.gz
Merge pull request #2255 from xeron/node_to_hash_run_list_fix
Make empty run_list to produce an empty array when using node.to_hash
-rw-r--r--lib/chef/node.rb4
-rw-r--r--spec/unit/node_spec.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 327da67b1c..5f788af4d4 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -397,7 +397,7 @@ class Chef
end
index_hash["recipe"] = run_list.recipe_names if run_list.recipe_names.length > 0
index_hash["role"] = run_list.role_names if run_list.role_names.length > 0
- index_hash["run_list"] = run_list.run_list if run_list.run_list.length > 0
+ index_hash["run_list"] = run_list.run_list_items
index_hash
end
@@ -409,7 +409,7 @@ class Chef
display["normal"] = normal_attrs
display["default"] = attributes.combined_default
display["override"] = attributes.combined_override
- display["run_list"] = run_list.run_list
+ display["run_list"] = run_list.run_list_items
display
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 00879dcb13..da7a67aec1 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -700,6 +700,10 @@ describe Chef::Node do
h["run_list"].should be_include("recipe[stalinist]")
h["chef_environment"].should == "dev"
end
+
+ it 'should return an empty array for empty run_list' do
+ node.to_hash["run_list"].should == []
+ end
end
describe "converting to or from json" do