Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unexpected behaviour when inserting consecutive items with default positions #124

Closed
jonasschneider opened this issue May 31, 2014 · 3 comments

Comments

@jonasschneider
Copy link

Environment: Suppose Item has acts_as_list and a position column with default of 0.

  1. Insert an item A into the list. (a = Item.create!)
  2. Insert another item B into the list. (b = Item.create!)

Expected behaviour: a.position == 1, b.position == 2

Actual behaviour: a.position == 2, b.position == 1.

I believe the culprit is 3ebaffc. The setting of the top position there is causing the check in add_to_list_bottom at https://github.com/swanandp/acts_as_list/blob/3ebaffc2680a7ba4ca5bef175e35ab0207e28562/lib/acts_as_list/active_record/acts/list.rb#L290 to take the wrong branch, and reverse the positions on the items.

Am I missing something here, or is this a bug?

@jonasschneider
Copy link
Author

Also: this works as expected in 0.3.0, but is broken as described in 0.4.0.

@swanandp
Copy link
Contributor

swanandp commented Jul 2, 2014

Thanks for reporting. Does look like a side effect of 3ebaffc. Can you add a failing test case and send a PR?

@brendon
Copy link
Owner

brendon commented Apr 17, 2016

I thought I had this reproduced, but I couldn't reproduce it. I'm going to close this for now unless someone can provide a test case that shows the bug.

@brendon brendon closed this as completed Apr 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants