From 73c8d0d4701f10995c81633b912bc6dc65a2cf78 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sun, 21 Mar 2010 12:07:37 +0100 Subject: Fix #3186 - require function set relationship only on the last class Due to the fact that resource.set_parameter is overwriting the previous set_parameters, we were losing the previous relationships we set there, either in a previous call of require or in the same call. Signed-off-by: Brice Figureau --- spec/unit/parser/functions/require.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'spec/unit/parser/functions') diff --git a/spec/unit/parser/functions/require.rb b/spec/unit/parser/functions/require.rb index 532c06900..4e05069df 100755 --- a/spec/unit/parser/functions/require.rb +++ b/spec/unit/parser/functions/require.rb @@ -8,7 +8,7 @@ describe "the require function" do @catalog = stub 'catalog' @compiler = stub 'compiler', :catalog => @catalog - @resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false + @resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false, :[] => nil @scope = Puppet::Parser::Scope.new() @scope.stubs(:resource).returns @resource @scope.stubs(:findresource) @@ -28,7 +28,7 @@ describe "the require function" do end it "should set the 'require' prarameter on the resource to a resource reference" do - @resource.expects(:set_parameter).with { |name, value| name == :require and value.is_a?(Puppet::Parser::Resource::Reference) } + @resource.expects(:set_parameter).with { |name, value| name == :require and value[0].is_a?(Puppet::Parser::Resource::Reference) } @scope.stubs(:function_include) @scope.function_require("myclass") end @@ -56,4 +56,14 @@ describe "the require function" do @scope.function_require("myclass") end + + it "should append the required class to the require parameter" do + @scope.stubs(:function_include) + Puppet::Parser::Resource::Reference.stubs(:new).returns(:require2) + + @resource.expects(:[]).with(:require).returns(:require1) + @resource.expects(:set_parameter).with(:require, [:require1, :require2]) + + @scope.function_require("myclass") + end end -- cgit