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
a06c7a6a
Commit
a06c7a6a
authored
Apr 11, 2019
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix usage ping for Epic#deepest_relationship_level
Returns nil if there are no epics
parent
b966a02e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
30 deletions
+26
-30
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+1
-6
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+25
-24
No files found.
ee/app/models/ee/epic.rb
View file @
a06c7a6a
...
...
@@ -159,12 +159,7 @@ module EE
def
deepest_relationship_level
return
unless
supports_nested_objects?
hierarchy
=
::
Gitlab
::
ObjectHierarchy
.
new
(
self
.
where
.
not
(
parent_id:
nil
))
deepest_level
=
hierarchy
.
max_descendants_depth
||
0
# For performance reasons, epics without a parent_id are being ignored in the query.
# So we add 1 to the result to take into account the first parent.
deepest_level
+
1
::
Gitlab
::
ObjectHierarchy
.
new
(
self
.
where
(
parent_id:
nil
)).
max_descendants_depth
end
def
update_start_and_due_dates
(
epics
)
...
...
ee/spec/models/epic_spec.rb
View file @
a06c7a6a
require
'spec_helper'
describe
Epic
do
l
et
(
:group
)
{
create
(
:group
)
}
s
et
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
describe
'associations'
do
...
...
@@ -16,7 +16,7 @@ describe Epic do
end
describe
'validations'
do
subject
{
create
(
:epic
)
}
subject
{
build
(
:epic
)
}
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
it
{
is_expected
.
to
validate_presence_of
(
:author
)
}
...
...
@@ -86,33 +86,29 @@ describe Epic do
end
end
describe
'#ancestors'
,
:nested_groups
do
set
(
:group
)
{
create
(
:group
)
}
set
(
:epic1
)
{
create
(
:epic
,
group:
group
)
}
set
(
:epic2
)
{
create
(
:epic
,
group:
group
,
parent:
epic1
)
}
set
(
:epic3
)
{
create
(
:epic
,
group:
group
,
parent:
epic2
)
}
it
'returns all ancestors for an epic'
do
expect
(
epic3
.
ancestors
).
to
eq
[
epic2
,
epic1
]
end
it
'returns an empty array if an epic does not have any parent'
do
expect
(
epic1
.
ancestors
).
to
be_empty
end
end
describe
'#descendants'
,
:nested_groups
do
let
(
:group
)
{
create
(
:group
)
}
context
'hierarchy'
do
let
(
:epic1
)
{
create
(
:epic
,
group:
group
)
}
let
(
:epic2
)
{
create
(
:epic
,
group:
group
,
parent:
epic1
)
}
let
(
:epic3
)
{
create
(
:epic
,
group:
group
,
parent:
epic2
)
}
it
'returns all ancestors for an epic'
do
expect
(
epic1
.
descendants
).
to
match_array
([
epic2
,
epic3
])
describe
'#ancestors'
,
:nested_groups
do
it
'returns all ancestors for an epic'
do
expect
(
epic3
.
ancestors
).
to
eq
[
epic2
,
epic1
]
end
it
'returns an empty array if an epic does not have any parent'
do
expect
(
epic1
.
ancestors
).
to
be_empty
end
end
it
'returns an empty array if an epic does not have any descendants'
do
expect
(
epic3
.
descendants
).
to
be_empty
describe
'#descendants'
,
:nested_groups
do
it
'returns all ancestors for an epic'
do
expect
(
epic1
.
descendants
).
to
match_array
([
epic2
,
epic3
])
end
it
'returns an empty array if an epic does not have any descendants'
do
expect
(
epic3
.
descendants
).
to
be_empty
end
end
end
...
...
@@ -465,6 +461,12 @@ describe Epic do
end
describe
'.deepest_relationship_level'
,
:postgresql
do
context
'when there are no epics'
do
it
'returns nil'
do
expect
(
described_class
.
deepest_relationship_level
).
to
be_nil
end
end
it
'returns the deepest relationship level between epics'
do
group_1
=
create
(
:group
)
group_2
=
create
(
:group
)
...
...
@@ -605,7 +607,6 @@ describe Epic do
end
context
'mentioning other objects'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
...
...
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