From 5a353c1cbaa3833ffd11c27cd9a07b7f4e0a43ec Mon Sep 17 00:00:00 2001 From: Ryan Bates Date: Mon, 30 Aug 2010 15:20:06 -0700 Subject: [PATCH] don't stop at cannot definition when checking class - closes #131 --- lib/cancan/can_definition.rb | 2 +- spec/cancan/ability_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cancan/can_definition.rb b/lib/cancan/can_definition.rb index 4b9c9f2..876f388 100644 --- a/lib/cancan/can_definition.rb +++ b/lib/cancan/can_definition.rb @@ -30,7 +30,7 @@ module CanCan elsif @conditions.kind_of?(Hash) && subject.class != Class matches_conditions_hash?(subject) else - true + @base_behavior end end diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index 1402e59..efe199e 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -246,6 +246,14 @@ describe CanCan::Ability do @ability.can?(:read, [[4, 5, 6]]).should be_false end + it "should not stop at cannot definition when comparing class" do + @ability.can :read, Array + @ability.cannot :read, Array, :first => 1 + @ability.can?(:read, [2,3,5]).should be_true + @ability.can?(:read, [1,3,5]).should be_false + @ability.can?(:read, Array).should be_true + end + it "should has eated cheezburger" do lambda { @ability.can? :has, :cheezburger