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