From 4da31c0709f4a8904980cffb8563cd41b16868e2 Mon Sep 17 00:00:00 2001 From: Ryan Bates Date: Tue, 20 Apr 2010 14:24:26 -0700 Subject: [PATCH] can has cheezburger? (thanks Seivan) --- lib/cancan/ability.rb | 1 + spec/cancan/ability_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/cancan/ability.rb b/lib/cancan/ability.rb index b2fbcf9..d173c65 100644 --- a/lib/cancan/ability.rb +++ b/lib/cancan/ability.rb @@ -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 diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index c51b22b..4aaa3ba 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -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