summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2019-08-01 12:41:42 +0000
committerBob Van Landuyt <bob@gitlab.com>2019-08-01 12:41:42 +0000
commitfc09bb0770ab74572cb2cf706180dce7503e19a0 (patch)
tree7c5a3d6c0a6f51f515da5868b8c485be73b2d436 /spec
parentbeb7d8922746942f1f4108108b04859ba61ea1ea (diff)
parent8992013689e358328d9ae74623b9b29d80f7b17b (diff)
downloadgitlab-ce-fc09bb0770ab74572cb2cf706180dce7503e19a0.tar.gz
Merge branch 'rename-relative-position-move-to-end' into 'master'
Fix bug when moving batches of items to the end See merge request gitlab-org/gitlab-ce!31351
Diffstat (limited to 'spec')
-rw-r--r--spec/support/shared_examples/relative_positioning_shared_examples.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/spec/support/shared_examples/relative_positioning_shared_examples.rb b/spec/support/shared_examples/relative_positioning_shared_examples.rb
index 5ee62644c54..45eacf3721e 100644
--- a/spec/support/shared_examples/relative_positioning_shared_examples.rb
+++ b/spec/support/shared_examples/relative_positioning_shared_examples.rb
@@ -9,24 +9,27 @@ RSpec.shared_examples "a class that supports relative positioning" do
create(factory, params.merge(default_params))
end
- describe '.move_to_end' do
- it 'moves the object to the end' do
- item1.update(relative_position: 5)
- item2.update(relative_position: 15)
-
- described_class.move_to_end([item1, item2])
+ describe '.move_nulls_to_end' do
+ it 'moves items with null relative_position to the end' do
+ described_class.move_nulls_to_end([item1, item2])
expect(item2.prev_relative_position).to eq item1.relative_position
expect(item1.prev_relative_position).to eq nil
expect(item2.next_relative_position).to eq nil
end
+ it 'moves the item near the start position when there are no existing positions' do
+ described_class.move_nulls_to_end([item1])
+
+ expect(item1.relative_position).to eq(described_class::START_POSITION + described_class::IDEAL_DISTANCE)
+ end
+
it 'does not perform any moves if all items have their relative_position set' do
item1.update!(relative_position: 1)
expect(item1).not_to receive(:save)
- described_class.move_to_end([item1])
+ described_class.move_nulls_to_end([item1])
end
end