summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-12-14 16:46:12 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-12-14 16:46:12 -0800
commit54799d8d25ed4565177f2a752088a220220c7344 (patch)
treef4e631d24ab6057cbfc821b8ba6d29fa1e51c7fd
parent5d16e1847ad20818651af2b39c08285d94772e69 (diff)
downloadchef-lcg/fix-tags-and-set-unless.tar.gz
really always return an Arraylcg/fix-tags-and-set-unless
-rw-r--r--lib/chef/node.rb3
-rw-r--r--spec/unit/node_spec.rb12
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index b2ef3aaf2f..0c13e5474a 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -1,4 +1,3 @@
-#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Christopher Brown (<cb@opscode.com>)
# Author:: Christopher Walters (<cw@opscode.com>)
@@ -372,7 +371,7 @@ class Chef
# Lazy initializer for tags attribute
def tags
- normal_unless[:tags] = []
+ normal[:tags] = Array(normal[:tags])
normal[:tags]
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 40e8cf8898..76cf451323 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -810,6 +810,18 @@ describe Chef::Node do
expect(node.tags).to eql([])
end
+ it "should return an array if it is fed a string" do
+ node.normal[:tags] = "string"
+ node.consume_external_attrs(@ohai_data, {})
+ expect(node.tags).to eql(["string"])
+ end
+
+ it "should return an array if it is fed a hash" do
+ node.normal[:tags] = {}
+ node.consume_external_attrs(@ohai_data, {})
+ expect(node.tags).to eql([])
+ end
+
it "deep merges attributes instead of overwriting them" do
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
expect(node.one.to_hash).to eq({"two" => {"three" => "four"}})