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
96e1bac3
Commit
96e1bac3
authored
Sep 09, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tests of private members
These are tested by their behavior
parent
66444cd3
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
309 deletions
+62
-309
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+18
-22
spec/support/shared_examples/models/relative_positioning_shared_examples.rb
...d_examples/models/relative_positioning_shared_examples.rb
+44
-287
No files found.
app/models/concerns/relative_positioning.rb
View file @
96e1bac3
...
...
@@ -323,6 +323,14 @@ module RelativePositioning
end
end
def
context
(
object
,
ignoring:
nil
)
return
unless
object
c
=
ItemContext
.
new
(
object
,
range
)
c
.
ignoring
=
ignoring
c
end
private
def
gap_too_small?
(
pos_a
,
pos_b
)
...
...
@@ -383,14 +391,6 @@ module RelativePositioning
end
end
def
context
(
object
,
ignoring:
nil
)
return
unless
object
c
=
ItemContext
.
new
(
object
,
range
)
c
.
ignoring
=
ignoring
c
end
# This method takes two integer values (positions) and
# calculates the position between them. The range is huge as
# the maximum integer value is 2147483647.
...
...
@@ -463,7 +463,7 @@ module RelativePositioning
private
# @api private
def
gap_size
(
objec
t
,
gaps
:,
at_end
:,
starting_from
:)
def
gap_size
(
contex
t
,
gaps
:,
at_end
:,
starting_from
:)
total_width
=
IDEAL_DISTANCE
*
gaps
size
=
if
at_end
&&
starting_from
+
total_width
>=
MAX_POSITION
(
MAX_POSITION
-
starting_from
)
/
gaps
...
...
@@ -473,23 +473,17 @@ module RelativePositioning
IDEAL_DISTANCE
end
# Shift max elements leftwards if there isn't enough space
return
[
size
,
starting_from
]
if
size
>=
MIN_GAP
order
=
at_end
?
:desc
:
:asc
terminus
=
object
.
send
(
:relative_siblings
)
# rubocop:disable GitlabSecurity/PublicSend
.
where
(
'relative_position IS NOT NULL'
)
.
order
(
relative_position:
order
)
.
first
if
at_end
terminus
.
move_sequence_before
(
true
)
max_relative_position
=
terminus
.
reset
.
relative_position
terminus
=
context
.
max_sibling
terminus
.
shift_left
max_relative_position
=
terminus
.
relative_position
[[(
MAX_POSITION
-
max_relative_position
)
/
gaps
,
IDEAL_DISTANCE
].
min
,
max_relative_position
]
else
terminus
.
move_sequence_after
(
true
)
min_relative_position
=
terminus
.
reset
.
relative_position
terminus
=
min_sibling
terminus
.
shift_right
min_relative_position
=
terminus
.
relative_position
[[(
min_relative_position
-
MIN_POSITION
)
/
gaps
,
IDEAL_DISTANCE
].
min
,
min_relative_position
]
end
end
...
...
@@ -507,8 +501,10 @@ module RelativePositioning
objects
=
objects
.
reject
(
&
:relative_position
)
return
0
if
objects
.
empty?
representative
=
objects
.
first
number_of_gaps
=
objects
.
size
# 1 to the nearest neighbour, and one between each
mover
=
Mover
.
new
(
START_POSITION
,
(
MIN_POSITION
..
MAX_POSITION
))
representative
=
mover
.
context
(
objects
.
first
)
position
=
if
at_end
representative
.
max_relative_position
else
...
...
spec/support/shared_examples/models/relative_positioning_shared_examples.rb
View file @
96e1bac3
This diff is collapsed.
Click to expand it.
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