There was an intermittent bug in Puppet::Parser::Resource::Reference,
during initialization, and object could sometimes have its title set
before its type is set. This prevented the title from going through
type-specific canonicalization.

Signed-off-by: Jesse Wolfe <[email protected]>
---
 lib/puppet/resource/reference.rb       |    4 ++++
 spec/unit/parser/resource.rb           |   11 +++++++++++
 spec/unit/parser/resource/reference.rb |    7 +++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/resource/reference.rb b/lib/puppet/resource/reference.rb
index dce4449..eddb2d9 100644
--- a/lib/puppet/resource/reference.rb
+++ b/lib/puppet/resource/reference.rb
@@ -50,6 +50,10 @@ class Puppet::Resource::Reference
             # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
             x = @type = value.to_s.split("::").collect { |s| s.capitalize 
}.join("::")
         end
+
+        if @title
+            self.title = @title
+        end
     end
 
     # Convert to the reference format that TransObject uses.  Yay backward
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 3f08de9..d41d4f4 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -101,6 +101,17 @@ describe Puppet::Parser::Resource do
         end
     end
 
+    describe "when refering to a resource with name canonicalization" do
+        before do
+            @arguments = {:type => "file", :title => "/path/", :scope => 
stub('scope', :source => mock('source'))}
+        end
+
+        it "should canonicalize its own name" do
+            res = Puppet::Parser::Resource.new(@arguments)
+            res.ref.should == "File[/path]"
+        end
+    end
+
     describe "when evaluating" do
         before do
             @type = Puppet::Parser::Resource
diff --git a/spec/unit/parser/resource/reference.rb 
b/spec/unit/parser/resource/reference.rb
index a703f92..19fe076 100755
--- a/spec/unit/parser/resource/reference.rb
+++ b/spec/unit/parser/resource/reference.rb
@@ -49,6 +49,13 @@ describe Puppet::Parser::Resource::Reference do
         ref = @type.new(:type => "file", :title => "/tmp/yay/")
         ref.to_s.should == "File[/tmp/yay]"
     end
+
+    it "should canonize resource reference values without order dependencies" 
do
+        args = [[:title, "/tmp/yay/"], [:type, "file"]]
+        ref = @type.new(args)
+        ref.to_s.should == "File[/tmp/yay]"
+    end
+
 end
 
 describe Puppet::Parser::Resource::Reference, " when modeling defined types" do
-- 
1.6.5

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to