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
a2b64174
Commit
a2b64174
authored
May 29, 2019
by
Brett Walker
Committed by
Nick Thomas
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow finding epics by iid
and adding has_issues? to an epic
parent
3469e336
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
104 additions
and
9 deletions
+104
-9
ee/app/finders/epics_finder.rb
ee/app/finders/epics_finder.rb
+9
-1
ee/app/helpers/ee/issuables_helper.rb
ee/app/helpers/ee/issuables_helper.rb
+1
-0
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+5
-1
ee/app/serializers/linked_epic_entity.rb
ee/app/serializers/linked_epic_entity.rb
+17
-1
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+1
-0
ee/spec/finders/epics_finder_spec.rb
ee/spec/finders/epics_finder_spec.rb
+18
-1
ee/spec/fixtures/api/schemas/public_api/v4/linked_epic.json
ee/spec/fixtures/api/schemas/public_api/v4/linked_epic.json
+2
-1
ee/spec/helpers/ee/issuables_helper_spec.rb
ee/spec/helpers/ee/issuables_helper_spec.rb
+1
-0
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+28
-0
ee/spec/services/epic_links/list_service_spec.rb
ee/spec/services/epic_links/list_service_spec.rb
+22
-4
No files found.
ee/app/finders/epics_finder.rb
View file @
a2b64174
...
...
@@ -33,6 +33,7 @@ class EpicsFinder < IssuableFinder
items
=
by_state
(
items
)
items
=
by_label
(
items
)
items
=
by_parent
(
items
)
items
=
by_iids
(
items
)
sort
(
items
)
end
...
...
@@ -49,7 +50,14 @@ class EpicsFinder < IssuableFinder
# rubocop: disable CodeReuse/ActiveRecord
def
init_collection
groups
=
groups_user_can_read_epics
(
group
.
self_and_descendants
)
groups
=
if
params
[
:iids
].
present?
# If we are querying for specific iids, then we should only be looking at
# those in the group, not any sub-groups (which can have identical iids).
# The `group` method takes care of checking permissions
[
group
]
else
groups_user_can_read_epics
(
group
.
self_and_descendants
)
end
Epic
.
where
(
group:
groups
)
end
...
...
ee/app/helpers/ee/issuables_helper.rb
View file @
a2b64174
...
...
@@ -22,6 +22,7 @@ module EE
data
[
:issueLinksEndpoint
]
=
group_epic_issues_path
(
parent
,
issuable
)
data
[
:epicLinksEndpoint
]
=
group_epic_links_path
(
parent
,
issuable
)
data
[
:subepicsSupported
]
=
::
Epic
.
supports_nested_objects?
data
[
:fullPath
]
=
parent
.
full_path
end
data
...
...
ee/app/models/ee/epic.rb
View file @
a2b64174
...
...
@@ -280,7 +280,11 @@ module EE
end
def
has_children?
issues
.
any?
||
descendants
.
any?
descendants
.
any?
end
def
has_issues?
issues
.
any?
end
def
child?
(
id
)
...
...
ee/app/serializers/linked_epic_entity.rb
View file @
a2b64174
...
...
@@ -3,7 +3,7 @@
class
LinkedEpicEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:id
,
:
title
,
:state
expose
:id
,
:
iid
,
:title
,
:state
,
:created_at
,
:closed_at
expose
:reference
do
|
epic
|
epic
.
to_reference
(
request
.
issuable
.
group
)
...
...
@@ -16,4 +16,20 @@ class LinkedEpicEntity < Grape::Entity
expose
:relation_path
do
|
epic
|
group_epic_link_path
(
request
.
issuable
.
group
,
request
.
issuable
.
iid
,
epic
.
id
)
end
expose
:has_children
do
|
epic
|
epic
.
has_children?
end
expose
:has_issues
do
|
epic
|
epic
.
has_issues?
end
expose
:full_path
do
|
epic
|
epic
.
group
.
full_path
end
expose
:can_admin
do
|
epic
|
can?
(
request
.
current_user
,
:admin_epic
,
epic
)
end
end
ee/lib/ee/api/entities.rb
View file @
a2b64174
...
...
@@ -208,6 +208,7 @@ module EE
expose
:group_id
expose
:parent_id
expose
:has_children?
,
as: :has_children
expose
:has_issues?
,
as: :has_issues
expose
:reference
do
|
epic
|
epic
.
to_reference
(
epic
.
parent
.
group
)
end
...
...
ee/spec/finders/epics_finder_spec.rb
View file @
a2b64174
...
...
@@ -27,7 +27,7 @@ describe EpicsFinder do
end
end
# Enab
e
ling the `request_store` for this to avoid counting queries that check
# Enabling the `request_store` for this to avoid counting queries that check
# the license.
context
'when epics feature is enabled'
,
:request_store
do
before
do
...
...
@@ -178,6 +178,23 @@ describe EpicsFinder do
expect
(
epics
(
params
)).
to
contain_exactly
(
epic2
)
end
end
context
'by iids'
do
let
(
:subgroup
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let!
(
:subepic1
)
{
create
(
:epic
,
group:
subgroup
,
iid:
epic1
.
iid
)
}
it
'returns the specified epics'
do
params
=
{
iids:
[
epic1
.
iid
,
epic2
.
iid
]
}
expect
(
epics
(
params
)).
to
contain_exactly
(
epic1
,
epic2
)
end
it
'does not return epics from the sub-group with the same iid'
do
params
=
{
iids:
[
epic1
.
iid
]
}
expect
(
epics
(
params
)).
to
contain_exactly
(
epic1
)
end
end
end
end
end
...
...
ee/spec/fixtures/api/schemas/public_api/v4/linked_epic.json
View file @
a2b64174
...
...
@@ -7,12 +7,13 @@
"group_id"
:
{
"type"
:
"integer"
},
"parent_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"has_children"
:
{
"type"
:
"boolean"
},
"has_issues"
:
{
"type"
:
"boolean"
},
"reference"
:
{
"type"
:
"string"
},
"url"
:
{
"type"
:
"string"
},
"relation_url"
:
{
"type"
:
"string"
}
},
"required"
:
[
"id"
,
"iid"
,
"group_id"
,
"title"
,
"parent_id"
,
"has_children"
,
"reference"
,
"url"
,
"relation_url"
"id"
,
"iid"
,
"group_id"
,
"title"
,
"parent_id"
,
"has_children"
,
"
has_issues"
,
"
reference"
,
"url"
,
"relation_url"
],
"additionalProperties"
:
false
}
ee/spec/helpers/ee/issuables_helper_spec.rb
View file @
a2b64174
...
...
@@ -29,6 +29,7 @@ describe IssuablesHelper do
markdownDocsPath:
'/help/user/markdown'
,
issuableTemplates:
nil
,
lockVersion:
epic
.
lock_version
,
fullPath:
@group
.
full_path
,
groupPath:
@group
.
path
,
initialTitleHtml:
epic
.
title
,
initialTitleText:
epic
.
title
,
...
...
ee/spec/models/epic_spec.rb
View file @
a2b64174
...
...
@@ -722,6 +722,34 @@ describe Epic do
end
end
describe
'#has_children?'
do
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
it
'has no children'
do
expect
(
epic
.
has_children?
).
to
be_falsey
end
it
'has child epics'
do
create
(
:epic
,
group:
group
,
parent:
epic
)
expect
(
epic
.
has_children?
).
to
be_truthy
end
end
describe
'#has_issues?'
do
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
it
'has no issues'
do
expect
(
epic
.
has_issues?
).
to
be_falsey
end
it
'has child issues'
do
create
(
:epic_issue
,
epic:
epic
,
issue:
create
(
:issue
))
expect
(
epic
.
has_issues?
).
to
be_truthy
end
end
context
'mentioning other objects'
do
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
...
...
ee/spec/services/epic_links/list_service_spec.rb
View file @
a2b64174
...
...
@@ -14,15 +14,33 @@ describe EpicLinks::ListService, :postgresql do
epics
.
map
do
|
epic
|
{
id:
epic
.
id
,
iid:
epic
.
iid
,
title:
epic
.
title
,
state:
epic
.
state
,
created_at:
epic
.
created_at
,
closed_at:
epic
.
closed_at
,
reference:
epic
.
to_reference
(
group
),
path:
"/groups/
#{
epic
.
group
.
full_path
}
/-/epics/
#{
epic
.
iid
}
"
,
relation_path:
"/groups/
#{
parent_epic
.
group
.
full_path
}
/-/epics/
#{
parent_epic
.
iid
}
/links/
#{
epic
.
id
}
"
relation_path:
"/groups/
#{
parent_epic
.
group
.
full_path
}
/-/epics/
#{
parent_epic
.
iid
}
/links/
#{
epic
.
id
}
"
,
has_children:
epic
.
has_children?
,
has_issues:
epic
.
has_issues?
,
full_path:
epic
.
group
.
full_path
,
can_admin:
Ability
.
allowed?
(
user
,
:admin_epic
,
epic
)
}
end
end
def
expect_results_are_equal
(
results
,
expected
)
results
.
each_index
do
|
index
|
expect
(
results
[
index
][
:created_at
]).
to
be_like_time
(
expected
[
index
][
:created_at
])
end
results
.
each
{
|
h
|
h
.
delete
(
:created_at
)
}
expected
.
each
{
|
h
|
h
.
delete
(
:created_at
)
}
expect
(
results
).
to
eq
(
expected
)
end
describe
'#execute'
do
subject
{
described_class
.
new
(
parent_epic
,
user
).
execute
}
...
...
@@ -47,7 +65,7 @@ describe EpicLinks::ListService, :postgresql do
it
'returns related issues JSON'
do
expected_result
=
epics_to_results
([
epic1
,
epic2
])
expect
(
subject
).
to
eq
(
expected_result
)
expect
_results_are_equal
(
subject
,
expected_result
)
end
end
...
...
@@ -62,7 +80,7 @@ describe EpicLinks::ListService, :postgresql do
expected_result
=
epics_to_results
([
epic1
,
epic2
,
epic_subgroup2
,
epic_subgroup1
])
expect
(
subject
).
to
eq
(
expected_result
)
expect
_results_are_equal
(
subject
,
expected_result
)
end
it
'returns only some child epics for a subgroup member'
do
...
...
@@ -70,7 +88,7 @@ describe EpicLinks::ListService, :postgresql do
expected_result
=
epics_to_results
([
epic1
,
epic2
,
epic_subgroup2
])
expect
(
subject
).
to
eq
(
expected_result
)
expect
_results_are_equal
(
subject
,
expected_result
)
end
end
end
...
...
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