can has cheezburger? (thanks Seivan)

This commit is contained in:
Ryan Bates 2010-04-20 14:24:26 -07:00
parent 5aa6252df6
commit 4da31c0709
2 changed files with 7 additions and 0 deletions

View File

@ -48,6 +48,7 @@ module CanCan
# end
#
def can?(action, subject, *extra_args)
raise Error, "Nom nom nom. I eated it." if action == :has && subject == :cheezburger
can_definition = matching_can_definition(action, subject)
can_definition && can_definition.can?(action, subject, extra_args)
end

View File

@ -188,4 +188,10 @@ describe CanCan::Ability do
it "should return false when performed on an action which isn't defined" do
@ability.conditions(:foo, Array).should == false
end
it "should has eated cheezburger" do
lambda {
@ability.can? :has, :cheezburger
}.should raise_exception(CanCan::Error, "Nom nom nom. I eated it.")
end
end