Skip to content

Not correctly sorting when moving to a node with uninitialized sort_order #18

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 4, 2012

Conversation

elhoyos
Copy link
Contributor

@elhoyos elhoyos commented Sep 3, 2012

The order of the nodes is not correctly reflected with *siblings* retrieval methods.

Harder failing tests when moving to a node with uninitialized sort_order
@travisbot
Copy link

This pull request fails (merged 2f2c53c into c85a605).

@elhoyos
Copy link
Contributor Author

elhoyos commented Sep 3, 2012

Adding the following to add_sibling method should be enough

self.order_value = 0 if self.order_value.nil?

But the resultset of

labels(:f3).self_and_siblings.to_a.should

on the first new test keeps failing for me.

Any clue on this?

@mceachen
Copy link
Collaborator

mceachen commented Sep 4, 2012

The self.order_value.to_i will already return 0 if the order_value is nil, because nil.to_i returns 0.

The problem was that the node that we appended to should have had an order_value set to 0 if we're going to assume the value is equivalent to 0 -- OR we could use an ifnull(), but that smells bad to me.

Thanks for the test, sir! You are a gentleman and a scholar.

@mceachen
Copy link
Collaborator

mceachen commented Sep 4, 2012

It's fixed in my new branch. I'll release a new version soon.

@mceachen mceachen merged commit 2f2c53c into ClosureTree:master Sep 4, 2012
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants