Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Changes rules order in mongoid specs. Fixes #672 #673

Merged
merged 1 commit into from Feb 22, 2013

Conversation

maxprokopiev
Copy link

Read more - #672

@andhapp
Copy link
Collaborator

andhapp commented Jul 4, 2012

@Juggler: Sorry, I think I misunderstood what you said. I thought you were going to fix that spec by changing the code. Changing the spec to get it passed still doesn't fix the original issue. I should have been more clear.

Please let us know your opinion.

@maxprokopiev
Copy link
Author

Yep, of course, this is not a fix.

My opinion is - maybe this is not an issue, maybe it's just an expected behaviour? I mean, when we combine rules, then we have to define them in a specific order - starting with more specific rules and ending with the most general rule. Am I right?

@andhapp
Copy link
Collaborator

andhapp commented Jul 5, 2012

That's the case when you want to use can and cannot rules together. Otherwise when you use multiple can rules they are logically or'ed. In that case, this needs to be fixed in the code.

@maxprokopiev
Copy link
Author

Um.. seems like in 2.0 version there is a change in ability precedence (see #321 and take a look at this commit - 6de9e46)

It says:

... generic rules will not override specific ones

And there is an example:

  it "takes presedence over rule defined without a condition" do
    @ability.can :read, :ranges
    @ability.can :read, :ranges, :begin => 1
    @ability.can?(:read, 1..5).should be_true
    @ability.can?(:read, 4..6).should be_false
  end

So, more specific rule (with conditions or attributes) will override general rule

@andhapp
Copy link
Collaborator

andhapp commented Jul 12, 2012

@Juggler: I stand corrected. I didn't know about change. I will request ryan to merge this one. Thanks.

@maxprokopiev
Copy link
Author

any updates here? +)

@ryanb
Copy link
Owner

ryanb commented Feb 22, 2013

Sorry about the delay, merged in, thanks!

ryanb added a commit that referenced this pull request Feb 22, 2013
Changes rules order in mongoid specs. Fixes #672
@ryanb ryanb merged commit e6bf4c8 into ryanb:2.0 Feb 22, 2013
@maxprokopiev
Copy link
Author

@ryanb cool 👍
what do you think about #671? :)

@maxprokopiev maxprokopiev deleted the rules_order branch March 17, 2013 07:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants