[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:10:36 UTC 2011


The following commit has been merged in the experimental branch:
commit 3bb614525f625a688baf8d67c5a580f8a51f4cad
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Wed Mar 30 16:56:08 2011 -0700

    (#6749) fix an inheritance bug in ActionManager
    
    When we wrote class inheritance of actions for strings we didn't implement
    method (ahem, action) lookup correctly.  This changes that, by providing the
    implementation to our standards, along with appropriate tests.
    
    Reviewed-By: Pieter van de Bruggen <pieter at puppetlabs.com>

diff --git a/lib/puppet/string/action_manager.rb b/lib/puppet/string/action_manager.rb
index c980142..7d22a0c 100644
--- a/lib/puppet/string/action_manager.rb
+++ b/lib/puppet/string/action_manager.rb
@@ -32,7 +32,15 @@ module Puppet::String::ActionManager
 
   def get_action(name)
     @actions ||= {}
-    @actions[name.to_sym]
+    result = @actions[name.to_sym]
+    if result.nil?
+      if self.is_a?(Class) and superclass.respond_to?(:get_action)
+        result = superclass.get_action(name)
+      elsif self.class.respond_to?(:get_action)
+        result = self.class.get_action(name)
+      end
+    end
+    return result
   end
 
   def action?(name)
diff --git a/spec/unit/string/action_manager_spec.rb b/spec/unit/string/action_manager_spec.rb
index 3921f02..5ca55b3 100755
--- a/spec/unit/string/action_manager_spec.rb
+++ b/spec/unit/string/action_manager_spec.rb
@@ -213,4 +213,21 @@ describe Puppet::String::ActionManager do
       @instance.foo.should == "something"
     end
   end
+
+  describe "#get_action" do
+    let :parent_class do
+      parent_class = Class.new(Puppet::String)
+      parent_class.action(:foo) {}
+      parent_class
+    end
+
+    it "should check that we can find inherited actions when we are a class" do
+      Class.new(parent_class).get_action(:foo).name.should == :foo
+    end
+
+    it "should check that we can find inherited actions when we are an instance" do
+      instance = parent_class.new(:foo, '0.0.0')
+      instance.get_action(:foo).name.should == :foo
+    end
+  end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list