From 75eb1917f9331dcd7c54e707d431b041b7b6d0d9 Mon Sep 17 00:00:00 2001 From: Yura Sokolov Date: Tue, 25 May 2010 14:28:29 +0400 Subject: [PATCH] add test for single `cannot` definition --- spec/cancan/ability_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index cb43747..698b4a6 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -148,6 +148,16 @@ describe CanCan::Ability do end + it "should always return `false` for single cannot definition" do + @ability.cannot :read, Integer do |int| + int > 10 ? nil : ( int > 5 ) + end + @ability.can?(:read, "foo").should be_false + @ability.can?(:read, 3).should be_false + @ability.can?(:read, 8).should be_false + @ability.can?(:read, 123).should be_false + end + it "should pass to previous cannot definition, if block returns false or nil" do @ability.cannot :read, :all @ability.can :read, Integer do |int|