Please review pull request #372: (#11826) Fix error when no certs were printed to console from ca face opened by (domcleal)

Description:

When no hosts needed to be printed from the 'ca' face to console, an error was
hit when trying to add an integer to nil.

  • Opened: Sat Jan 21 20:36:24 UTC 2012
  • Based on: puppetlabs:2.7.x (470a6646b4faa34874ab853355730dc0471b1246)
  • Requested merge: domcleal:tickets/2.7.x/11826 (17ac2c17a963fa89bbdac52ec5b198bef0a94cde)

Diff follows:

diff --git a/lib/puppet/face/ca.rb b/lib/puppet/face/ca.rb
index 6688886..9b5e8d3 100644
--- a/lib/puppet/face/ca.rb
+++ b/lib/puppet/face/ca.rb
@@ -75,7 +75,7 @@
         raise "Unable to fetch the CA"
       end
 
-      length = hosts.map{|x| x.name.length }.max + 1
+      length = hosts.map{|x| x.name.length }.max.to_i + 1
 
       hosts.map do |host|
         name = host.name.ljust(length)
diff --git a/spec/unit/face/ca_spec.rb b/spec/unit/face/ca_spec.rb
index 018942e..f489fbc 100755
--- a/spec/unit/face/ca_spec.rb
+++ b/spec/unit/face/ca_spec.rb
@@ -312,16 +312,27 @@ def make_certs(csr_names, crt_names)
     end
 
     context "with no hosts in CA" do
-      [:pending, :signed, :all].each do |type|
-        it "should return nothing for #{type}" do
-          subject.list(type => true).should == []
+      [
+        {},
+        { :pending => true },
+        { :signed => true },
+        { :all => true },
+      ].each do |type|
+        it "should return nothing for #{type.inspect}" do
+          subject.list(type).should == []
         end
 
         it "should not fail when a matcher is passed" do
           expect {
-            subject.list(type => true, :subject => '.').should == []
+            subject.list(type.merge :subject => '.').should == []
           }.should_not raise_error
         end
+
+        context "when_rendering :console" do
+          it "should return nothing for #{type.inspect}" do
+            action.when_rendering(:console).call(subject.list(type)).should == ""
+          end
+        end
       end
     end
 

    

--
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