Commit dc21b8e6 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ajk-relative-positioning-open-range-fix' into 'master'

Fix placement for open ranges

See merge request gitlab-org/gitlab!40744
parents e05c63f0 079bfe38
......@@ -83,9 +83,9 @@ module RelativePositioning
if gap_width < MIN_GAP
raise NoSpaceLeft
elsif gap_width > MAX_GAP
if pos_before == MIN_POSITION
if pos_before <= MIN_POSITION
pos_after - IDEAL_DISTANCE
elsif pos_after == MAX_POSITION
elsif pos_after >= MAX_POSITION
pos_before + IDEAL_DISTANCE
else
midpoint
......
......@@ -4,6 +4,6 @@ FactoryBot.define do
factory :epic_issue do
epic
issue
relative_position { Gitlab::Database::MAX_INT_VALUE / 2 }
relative_position { RelativePositioning::START_POSITION }
end
end
......@@ -568,6 +568,12 @@ RSpec.shared_examples 'a class that supports relative positioning' do
end
end
it 'places items at most IDEAL_DISTANCE from the start when the range is open' do
n = item1.send(:scoped_items).count
expect([item1, item2].map(&:relative_position)).to all(be >= (RelativePositioning::START_POSITION - (n * RelativePositioning::IDEAL_DISTANCE)))
end
it 'moves item to the end' do
new_item.move_to_start
......@@ -613,6 +619,12 @@ RSpec.shared_examples 'a class that supports relative positioning' do
end
end
it 'places items at most IDEAL_DISTANCE from the start when the range is open' do
n = item1.send(:scoped_items).count
expect([item1, item2].map(&:relative_position)).to all(be <= (RelativePositioning::START_POSITION + (n * RelativePositioning::IDEAL_DISTANCE)))
end
it 'moves item to the end' do
new_item.move_to_end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment