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

merged 1 commit into from Feb 22, 2013


None yet
3 participants

Read more - #672


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.

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 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.

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

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


andhapp commented Jul 12, 2012

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

any updates here? +)


ryanb commented Feb 22, 2013

Sorry about the delay, merged in, thanks!

@ryanb ryanb added a commit that referenced this pull request Feb 22, 2013

@ryanb ryanb Merge pull request #673 from juggler/rules_order
Changes rules order in mongoid specs. Fixes #672

@ryanb ryanb merged commit e6bf4c8 into ryanb:2.0 Feb 22, 2013

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

maxprokopiev deleted the maxprokopiev:rules_order branch Mar 17, 2013

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