Permalink
Browse files

fix matches_conditons_hash for string values on 1.8

  • Loading branch information...
1 parent 60cf6a6 commit ea2b07f4163a47c7ce52cea2601cffea09ed8c50 @ryanb committed May 7, 2013
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/cancan/rule.rb
  2. +6 −0 spec/cancan/ability_spec.rb
View
@@ -116,7 +116,7 @@ def matches_conditions_hash?(subject, conditions = @conditions)
else
!attribute.nil? && matches_conditions_hash?(attribute, value)
end
- elsif value.kind_of?(Enumerable)
+ elsif !value.is_a?(String) && value.kind_of?(Enumerable)
value.include? attribute
else
attribute == value
@@ -269,6 +269,12 @@
@ability.can?(:read, []).should be_false
end
+ it "should match strings but not substrings specified in a conditions hash" do
+ @ability.can :read, String, :presence => "declassified"
+ @ability.can?(:read, "declassified").should be_true
+ @ability.can?(:read, "classified").should be_false
+ end
+
it "should not stop at cannot definition when comparing class" do
@ability.can :read, Range
@ability.cannot :read, Range, :begin => 1

0 comments on commit ea2b07f

Please sign in to comment.