summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-04-24 17:41:01 +0200
committerMarkus Roberts <Markus@reality.com>2010-06-28 14:19:54 -0700
commit153d7cd69b8b5216695206cbc235dd89a65dec76 (patch)
treec04f05a495bbbc72a29df86f2b1d0b881f77f614 /spec
parentdd4fa6686b31501ab8d8f800a81715e713b14031 (diff)
downloadpuppet-153d7cd69b8b5216695206cbc235dd89a65dec76.tar.gz
puppet-153d7cd69b8b5216695206cbc235dd89a65dec76.tar.xz
puppet-153d7cd69b8b5216695206cbc235dd89a65dec76.zip
Fix #3665 - part 2, node inheritance fixes
We were looking only to the class hierarchies when trying to find an ancestor to the current type. Thus we were never trying to climb up the hierarchy of nodes when evaluating nodes. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/resource/type_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index 2a8802c73..044b81e41 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -489,6 +489,47 @@ describe Puppet::Resource::Type do
@scope.class_scope(@type).parent.object_id.should == @scope.class_scope(@parent_type).object_id
end
end
+
+ describe "and it has a parent node" do
+ before do
+ @type = Puppet::Resource::Type.new(:node, "foo")
+ @parent_type = Puppet::Resource::Type.new(:node, "parent")
+ @type.parent = "parent"
+ @parent_resource = Puppet::Parser::Resource.new(:node, "parent", :scope => @scope)
+
+ @compiler.add_resource @scope, @parent_resource
+
+ @type.resource_type_collection = @scope.known_resource_types
+ @type.resource_type_collection.stubs(:node).with("parent").returns(@parent_type)
+ @type.resource_type_collection.stubs(:node).with("Parent").returns(@parent_type)
+ end
+
+ it "should evaluate the parent's resource" do
+ @type.evaluate_code(@resource)
+
+ @scope.class_scope(@parent_type).should_not be_nil
+ end
+
+ it "should not evaluate the parent's resource if it has already been evaluated" do
+ @parent_resource.evaluate
+
+ @parent_resource.expects(:evaluate).never
+
+ @type.evaluate_code(@resource)
+ end
+
+ it "should use a nodescope subscope" do
+ @type.evaluate_code(@resource)
+
+ @scope.class_scope(@type).nodescope.should be_true
+ end
+
+ it "should use the parent's scope as its base scope" do
+ @type.evaluate_code(@resource)
+
+ @scope.class_scope(@type).parent.object_id.should == @scope.class_scope(@parent_type).object_id
+ end
+ end
end
describe "when creating a resource" do