Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#223 Introduced a bug, by adding the branch condition to
move_lower
andmove_higher
, the order is still changed but if you are using a before save callback to spy on position change, the position for the second element is the same as the original due to a mistake inlib/acts_as_list/active_record/acts/list.rb:221
Previously:
This condition is checking that booth elements don't have the same position.
This changed behaviour not only for non regular sequence positions, but for all elements that don't have the same position, I argue this should only be entered for elements with a absolute distance between them bigger that 1.
Elements with a pair of positions
[1,2]
and[1,5]
will enter this condition, was this on propose?swap_position
doesn't do the same as the other part of the conditional branch for elements with positions1
and2
.item1.send("#{position_column}_was")
returns the same asitem1.send(position_column)
so my proposed solution it's to store item1 original position in a variable before we change it's position.