Fix rule check on Hash-like subjects

This commit is contained in:
Sam Pohlenz
2011-02-04 16:46:57 +10:30
parent b2028c8aa7
commit f23bbe04ef
2 changed files with 8 additions and 2 deletions

View File

@@ -290,6 +290,12 @@ describe CanCan::Ability do
@ability.can?(:read, "foobar" => Range).should be_false
@ability.can?(:read, 123 => Range).should be_true
end
it "should allow to check ability on Hash-like object" do
class Container < Hash; end
@ability.can :read, Container
@ability.can?(:read, Container.new).should be_true
end
it "should have initial attributes based on hash conditions of 'new' action" do
@ability.can :manage, Range, :foo => "foo", :hash => {:skip => "hashes"}