diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-01 01:57:04 +0800 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-01 02:04:10 +0800 |
commit | 8992013689e358328d9ae74623b9b29d80f7b17b (patch) | |
tree | 2242db40a6b13180192ea29544aac3fc85bb6036 /app/models/concerns/relative_positioning.rb | |
parent | 2e7f4bbb66b4bae61c9dd09234e8435c91e7e986 (diff) | |
download | gitlab-ce-8992013689e358328d9ae74623b9b29d80f7b17b.tar.gz |
Fix bug when moving batches of items to the endrename-relative-position-move-to-end
Starts from START_POSITION when there are no existing
positions.
Also improves the test to actually test the behavior
Diffstat (limited to 'app/models/concerns/relative_positioning.rb')
-rw-r--r-- | app/models/concerns/relative_positioning.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb index 9cd7b8d6258..4a1441805fc 100644 --- a/app/models/concerns/relative_positioning.rb +++ b/app/models/concerns/relative_positioning.rb @@ -34,7 +34,7 @@ module RelativePositioning end class_methods do - def move_to_end(objects) + def move_nulls_to_end(objects) objects = objects.reject(&:relative_position) return if objects.empty? @@ -43,7 +43,7 @@ module RelativePositioning self.transaction do objects.each do |object| - relative_position = position_between(max_relative_position, MAX_POSITION) + relative_position = position_between(max_relative_position || START_POSITION, MAX_POSITION) object.relative_position = relative_position max_relative_position = relative_position object.save(touch: false) |