Fix a Mongoid spec by switching the rule creation order in it #689

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

Merging into: ryanb:2.0

Specific rules overrule/exclude generic rules and should therefore be defined first if both rules need to be evaluated.

An actual use case would be:

user.can :read, :documents, :user_id => user.id

if user.admin?
  user.can :read, :documents
end

relevant_rules # => [:read, :documents], [:read, :documents, {:user_id => user.id}]

and the following would then not work, because of the specificity rule.
Given, user.admin? #=> true:

if user.admin?
  user.can :read, :documents
end

user.can :read, :documents, :user_id => user.id

relevant_rules # => [:read, :documents, {:user_id => user.id}]

Switch rule creation order
Specific rules overrule generic rules and should
therefore be defined first if both rules need
to be evaluated

Can you try the most recent version of cancan (currently 1.6.10) to see if your issue has been resolved?

This is one of the oldest CanCan issues with no discussion. CanCan is struggling right now to implement support for rails 4, and the issue count is nearing 200. It would be a big help if we could close a few old issues and get the issue count down. Thanks!

Githubs UI updates really obfuscate more then help here, but this is for the 2.0 branch. I haven't tested it on 1.6.x a year ago, and I'm not sure it would help you getting rails 4 support.

I think its best if we close this issue.

@suweller suweller closed this Jul 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment