summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/resource.rb4
-rwxr-xr-xspec/unit/parser/resource.rb8
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index d4c7a1f0f..47dc798b3 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -289,6 +289,10 @@ class Puppet::Parser::Resource
if v.is_a?(Puppet::Parser::Resource::Reference)
v = Puppet::Resource::Reference.new(v.type, v.title)
elsif v.is_a?(Array)
+ # flatten resource references arrays
+ if v.flatten.find { |av| av.is_a?(Puppet::Parser::Resource::Reference) }
+ v = v.flatten
+ end
v = v.collect do |av|
if av.is_a?(Puppet::Parser::Resource::Reference)
av = Puppet::Resource::Reference.new(av.type, av.title)
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 410494d43..92699e040 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -425,5 +425,13 @@ describe Puppet::Parser::Resource do
result = @parser_resource.to_resource
result[:fee].should == ["a", Puppet::Resource::Reference.new(:file, "/my/file")]
end
+
+ it "should convert any parser resource references to Puppet::Resource::Reference instances even if they are in an array of array, and even deeper" do
+ ref1 = Puppet::Parser::Resource::Reference.new(:title => "/my/file1", :type => "file")
+ ref2 = Puppet::Parser::Resource::Reference.new(:title => "/my/file2", :type => "file")
+ @parser_resource = mkresource :source => @source, :params => {:foo => "bar", :fee => ["a", [ref1,ref2]]}
+ result = @parser_resource.to_resource
+ result[:fee].should == ["a", Puppet::Resource::Reference.new(:file, "/my/file1"), Puppet::Resource::Reference.new(:file, "/my/file2")]
+ end
end
end