summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-06-01 11:53:40 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-06-01 11:53:40 -0700
commit796900b04e234b61a77fe4b64c006f24e15a7360 (patch)
tree43d4af311ea97c19fa8518ab44f004f512851950 /spec/unit
parent0370011a95d90ce0ff6ee7277d96021b3f3c8744 (diff)
downloadpuppet-796900b04e234b61a77fe4b64c006f24e15a7360.tar.gz
puppet-796900b04e234b61a77fe4b64c006f24e15a7360.tar.xz
puppet-796900b04e234b61a77fe4b64c006f24e15a7360.zip
(#7699) Don't duplicate inherited action names on faces.
We earlier moved to duplicating Action objects in the Faces subsystem to ensure they had the correct binding context during execution and introspection. This was correct, but introduced a bug where we would report both the parent and child binding as separate entries with duplicate names, in the list of actions. This flowed on to the help output, where it would cause every inherited action to be listed twice: once on the parent, once on the child. (This was actually worse if the inheritance was deeper: we would duplicate once for every level between the instance and the origin of the action.)
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/interface/action_manager_spec.rb50
1 files changed, 38 insertions, 12 deletions
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb
index e357a5fa1..3a84e4f83 100755
--- a/spec/unit/interface/action_manager_spec.rb
+++ b/spec/unit/interface/action_manager_spec.rb
@@ -186,23 +186,49 @@ describe Puppet::Interface::ActionManager do
@instance.should be_action(:foo)
end
- it "should list actions defined in superclasses" do
- @subclass = Class.new(@klass)
- @instance = @subclass.new
+ context "with actions defined in superclass" do
+ before :each do
+ @subclass = Class.new(@klass)
+ @instance = @subclass.new
+
+ @klass.action(:parent) do
+ when_invoked { |options| "a" }
+ end
+ @subclass.action(:sub) do
+ when_invoked { |options| "a" }
+ end
+ @instance.action(:instance) do
+ when_invoked { |options| "a" }
+ end
+ end
+
+ it "should list actions defined in superclasses" do
+ @instance.should be_action(:parent)
+ @instance.should be_action(:sub)
+ @instance.should be_action(:instance)
+ end
- @klass.action(:parent) do
- when_invoked { |options| "a" }
+ it "should list inherited actions" do
+ @instance.actions.should =~ [:instance, :parent, :sub]
end
- @subclass.action(:sub) do
- when_invoked { |options| "a" }
+
+ it "should not duplicate instance actions after fetching them (#7699)" do
+ @instance.actions.should =~ [:instance, :parent, :sub]
+ @instance.get_action(:instance)
+ @instance.actions.should =~ [:instance, :parent, :sub]
end
- @instance.action(:instance) do
- when_invoked { |options| "a" }
+
+ it "should not duplicate subclass actions after fetching them (#7699)" do
+ @instance.actions.should =~ [:instance, :parent, :sub]
+ @instance.get_action(:sub)
+ @instance.actions.should =~ [:instance, :parent, :sub]
end
- @instance.should be_action(:parent)
- @instance.should be_action(:sub)
- @instance.should be_action(:instance)
+ it "should not duplicate superclass actions after fetching them (#7699)" do
+ @instance.actions.should =~ [:instance, :parent, :sub]
+ @instance.get_action(:parent)
+ @instance.actions.should =~ [:instance, :parent, :sub]
+ end
end
it "should create an instance method when an action is defined in a superclass" do