consider ancestors when matching classes in Ability#can, this way it works with STI - closes #55

This commit is contained in:
Ryan Bates
2010-08-06 10:06:37 -07:00
parent a157b65fbf
commit 961b8c2477
2 changed files with 12 additions and 1 deletions

View File

@@ -135,6 +135,13 @@ describe CanCan::Ability do
@ability.can?(:read, :nonstats).should be_false
end
it "should check ancestors of class" do
@ability.can :read, Numeric
@ability.can?(:read, Integer).should be_true
@ability.can?(:read, 1.23).should be_true
@ability.can?(:read, "foo").should be_false
end
it "should support 'cannot' method to define what user cannot do" do
@ability.can :read, :all
@ability.cannot :read, Integer