adding cannot method to define which abilities cannot be done - closes #7

This commit is contained in:
Ryan Bates
2009-11-25 10:25:58 -08:00
parent e60365505c
commit d4405e6070
4 changed files with 59 additions and 14 deletions

View File

@@ -106,4 +106,21 @@ describe CanCan::Ability do
@ability.can?(:update, :stats).should be_false
@ability.can?(:read, :nonstats).should be_false
end
it "should support 'cannot' method to define what user cannot do" do
@ability.can :read, :all
@ability.cannot :read, Integer
@ability.can?(:read, "foo").should be_true
@ability.can?(:read, 123).should be_false
end
it "should support block on 'cannot' method" do
@ability.can :read, :all
@ability.cannot :read, Integer do |int|
int > 5
end
@ability.can?(:read, "foo").should be_true
@ability.can?(:read, 3).should be_true
@ability.can?(:read, 123).should be_false
end
end