summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/node/configuration.rb1
-rw-r--r--lib/puppet/type.rb4
-rwxr-xr-xspec/unit/node/configuration.rb15
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index 8cb6ed1f9..9cd23926e 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -47,6 +47,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
else
@resource_table[ref] = resource
end
+ resource.configuration = self
add_vertex!(resource)
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index b4b6e3b18..03f571d4a 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -44,7 +44,9 @@ class Type
# that it is clear whether it operates on all attributes (thus has 'attr' in
# the method name, or whether it operates on a specific type of attributes.
attr_accessor :file, :line
- attr_reader :parent
+
+ # The configuration that this resource is stored in.
+ attr_accessor :configuration
attr_writer :title
attr_writer :noop
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 3c30d9b3e..071afc041 100755
--- a/spec/unit/node/configuration.rb
+++ b/spec/unit/node/configuration.rb
@@ -137,9 +137,9 @@ end
describe Puppet::Node::Configuration, " when functioning as a resource container" do
before do
@config = Puppet::Node::Configuration.new("host")
- @one = stub 'resource1', :ref => "Me[you]"
- @two = stub 'resource2', :ref => "Me[him]"
- @dupe = stub 'resource3', :ref => "Me[you]"
+ @one = stub 'resource1', :ref => "Me[you]", :configuration= => nil
+ @two = stub 'resource2', :ref => "Me[him]", :configuration= => nil
+ @dupe = stub 'resource3', :ref => "Me[you]", :configuration= => nil
end
it "should make all vertices available by resource reference" do
@@ -182,6 +182,11 @@ describe Puppet::Node::Configuration, " when functioning as a resource container
conf.add_resource @two
end
end
+
+ it "should inform the resource that it is the resource's configuration" do
+ @one.expects(:configuration=).with(@config)
+ @config.add_resource @one
+ end
end
module ApplyingConfigurations
@@ -223,7 +228,9 @@ describe Puppet::Node::Configuration, " when applying" do
end
it "should yield the transaction if a block is provided" do
- pending "the code works but is not tested"
+ @config.apply do |trans|
+ trans.should equal(@transaction)
+ end
end
it "should default to not being a host configuration" do