Commit 84fd43cf authored by Alex Kalderimis's avatar Alex Kalderimis

Allow create_space methods to be called without args

parent 08314ee8
......@@ -171,12 +171,12 @@ module RelativePositioning
object.reset
end
def create_space_left(gap: nil)
move_sequence_before(false, next_gap: gap)
def create_space_left
find_next_gap_before.tap { |gap| move_sequence_before(false, next_gap: gap) }
end
def create_space_right(gap: nil)
move_sequence_after(false, next_gap: gap)
def create_space_right
find_next_gap_after.tap { |gap| move_sequence_after(false, next_gap: gap) }
end
# Moves the sequence before the current item to the middle of the next gap
......@@ -386,17 +386,12 @@ module RelativePositioning
return [pos_left, pos_right] unless gap_too_small?(pos_left, pos_right)
gap = rhs.find_next_gap_before
if gap.present?
rhs.create_space_left(gap: gap)
gap = rhs.create_space_left
[pos_left - gap.delta, pos_right]
else
gap = lhs.find_next_gap_after
lhs.create_space_right(gap: gap)
rescue NoSpaceLeft
gap = lhs.create_space_right
[pos_left, pos_right + gap.delta]
end
end
# This method takes two integer values (positions) and
# calculates the position between them. The range is huge as
......
......@@ -39,8 +39,8 @@ RSpec.describe EpicIssue do
let_it_be_with_reload(:middle) { create(:epic, group: epic.group, parent: epic, relative_position: 101) }
let_it_be_with_reload(:right) { create(:epic_issue, epic: epic, relative_position: 102) }
it 'can create space by using move_sequence_after' do
left.move_sequence_after
it 'can create space to the right' do
RelativePositioning.mover.context(left).create_space_right
[left, middle, right].each(&:reset)
expect(middle.relative_position - left.relative_position).to be > 1
......@@ -48,8 +48,8 @@ RSpec.describe EpicIssue do
expect(middle.relative_position).to be < right.relative_position
end
it 'can create space by using move_sequence_before' do
right.move_sequence_before
it 'can create space to the left' do
RelativePositioning.mover.context(right).create_space_left
[left, middle, right].each(&:reset)
expect(right.relative_position - middle.relative_position).to be > 1
......
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