Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged PR #564

  • Loading branch information...
commit 664e0b44f07762ec5fa7763a519d61ba49788f6b 1 parent b75b0ba
@Sija authored
Showing with 9 additions and 1 deletion.
  1. +1 −1  lib/cancan/rule.rb
  2. +8 −0 spec/cancan/ability_spec.rb
View
2  lib/cancan/rule.rb
@@ -127,7 +127,7 @@ def matches_conditions_hash?(subject, conditions = @conditions)
end
def nested_subject_matches_conditions?(subject_hash)
- parent, child = subject_hash.shift
+ parent, child = subject_hash.first
matches_conditions_hash?(parent, @conditions[parent.class.name.downcase.to_sym] || {})
end
View
8 spec/cancan/ability_spec.rb
@@ -306,6 +306,14 @@ class A; include B; end
@ability.can?(:read, 123 => Range).should be_true
end
+ it "passing a hash of subjects with multiple definitions should check permissions correctly" do
+ @ability.can :read, Range, :string => {:length => 4}
+ @ability.can [:create, :read], Range, :string => {:upcase => 'FOO'}
+ @ability.can?(:read, "foo" => Range).should be_true
+ @ability.can?(:read, "foobar" => Range).should be_false
+ @ability.can?(:read, 1234 => Range).should be_true
+ end
+
it "should allow to check ability on Hash-like object" do
class Container < Hash; end
@ability.can :read, Container
Please sign in to comment.
Something went wrong with that request. Please try again.