Created
June 20, 2012 18:51
-
-
Save jimweirich/2961532 to your computer and use it in GitHub Desktop.
Investigating "super unless allow" issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demonstrating the the "super unless allow?(method)" line *might* cause | |
# problems, but only under weird circumstances involving the ancestors | |
# of the Draper::Base class. Since the ancestor list is pretty stable, | |
# this probably isn't an issue (note I had to include a module into | |
# Draper::Base to trigger the problem -- Yikes!). | |
# | |
# So, after analysis, "super unless allow?" isn't a practical problem. | |
# | |
# HOWEVER, it would be nice for the code to reflect that it isn't a | |
# problem without requiring extensive research. | |
context "in weird inheritance tree" do | |
PING_COUNTER = [] | |
class NoPingDecorator < Decorator | |
denies :ping | |
end | |
module NastyAncestor | |
def method_missing(sym, *args, &block) | |
if sym == :ping | |
PING_COUNTER << :ping | |
else | |
super | |
end | |
end | |
end | |
class Draper::Base | |
include NastyAncestor | |
end | |
subject{ NoPingDecorator.new(source) } | |
it "is not called twice" do | |
PING_COUNTER.clear | |
subject.ping | |
PING_COUNTER.should == [:ping] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow.