Fix bug with CanDefinition#tableized_conditions being used with Mongoid documents and add more specs for accesible_by with Mongoid.

This commit is contained in:
Mani Tadayon
2010-10-14 17:39:19 -07:00
parent 25bf479f48
commit d256aeb26e
2 changed files with 24 additions and 8 deletions

View File

@@ -22,7 +22,7 @@ module CanCan
end
def conditions
@can_definitions.first.try(:tableized_conditions)
@can_definitions.first.instance_variable_get(:@conditions)
end
end
@@ -82,7 +82,8 @@ module CanCan
# Here only the articles which the user can update are returned. This
# internally uses Ability#conditions method, see that for more information.
def accessible_by(ability, action = :read)
query = ability.query(action, self)
query = ability.query(action, self)
if query.conditions.blank?
# this query is sure to return no results
# we need this so there is a Mongoid::Criteria object to return, since an empty array would cause problems