Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
84fd43cf
Commit
84fd43cf
authored
Sep 10, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow create_space methods to be called without args
parent
08314ee8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
18 deletions
+13
-18
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+9
-14
ee/spec/models/epic_issue_spec.rb
ee/spec/models/epic_issue_spec.rb
+4
-4
No files found.
app/models/concerns/relative_positioning.rb
View file @
84fd43cf
...
...
@@ -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
...
...
ee/spec/models/epic_issue_spec.rb
View file @
84fd43cf
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment