Browse files

can has cheezburger? (thanks Seivan)

  • Loading branch information...
1 parent 5aa6252 commit 4da31c0709f4a8904980cffb8563cd41b16868e2 @ryanb committed Apr 20, 2010
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/cancan/ability.rb
  2. +6 −0 spec/cancan/ability_spec.rb
1 lib/cancan/ability.rb
@@ -48,6 +48,7 @@ module Ability
# end
def can?(action, subject, *extra_args)
+ raise Error, "Nom nom nom. I eated it." if action == :has && subject == :cheezburger
iGEL Apr 20, 2010

Well, my tests also contain some jokes, but I'll try to keep them out of the app itself...

Arcath Apr 21, 2010

This will be very funny when someone with a cheezburger controller adds has as a custom action for a joke

can_definition = matching_can_definition(action, subject)
can_definition && can_definition.can?(action, subject, extra_args)
6 spec/cancan/ability_spec.rb
@@ -188,4 +188,10 @@
it "should return false when performed on an action which isn't defined" do
@ability.conditions(:foo, Array).should == false
+ it "should has eated cheezburger" do
+ lambda {
+ @ability.can? :has, :cheezburger
+ }.should raise_exception(CanCan::Error, "Nom nom nom. I eated it.")
+ end

3 comments on commit 4da31c0


CanCan: Enterprise Edition


And this, kids, is exactly why you shouldn't code after alcohol/drugs/too_much_internet ;)


And this, kids, is exactly why you should code after alcohol/drugs/too_much_internet :D


Please sign in to comment.