Commit 17e4fcbc authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ee-subepics' into 'master'

Include epics from subgroups

Closes #4301

See merge request gitlab-org/gitlab-ee!4182
parents f9a09067 34c90015
---
title: Include epics from subgroups on Epic index page
merge_request:
author:
type: fixed
...@@ -12,7 +12,7 @@ The [epic issues API](epic_issues.md) allows you to interact with issues associa ...@@ -12,7 +12,7 @@ The [epic issues API](epic_issues.md) allows you to interact with issues associa
## List epics for a group ## List epics for a group
Gets all epics of the requested group. Gets all epics of the requested group and its subgroups.
``` ```
GET /groups/:id/-/epics GET /groups/:id/-/epics
......
...@@ -9,7 +9,8 @@ milestones. ...@@ -9,7 +9,8 @@ milestones.
## Creating an epic ## Creating an epic
A paginated list of epics is available in each group from where you can create A paginated list of epics is available in each group from where you can create
a new epic. From your group page: a new epic. The list of epics includes also epics from all subgroups of the
selected group. From your group page:
1. Go to **Epics** 1. Go to **Epics**
1. Click the **New epic** button at the top right 1. Click the **New epic** button at the top right
......
...@@ -10,7 +10,6 @@ class EpicsFinder < IssuableFinder ...@@ -10,7 +10,6 @@ class EpicsFinder < IssuableFinder
items = by_created_at(items) items = by_created_at(items)
items = by_search(items) items = by_search(items)
items = by_author(items) items = by_author(items)
items = by_iids(items)
sort(items) sort(items)
end end
...@@ -37,6 +36,16 @@ class EpicsFinder < IssuableFinder ...@@ -37,6 +36,16 @@ class EpicsFinder < IssuableFinder
end end
def init_collection def init_collection
group.epics groups = groups_user_can_read_epics(group.self_and_descendants)
Epic.where(group: groups)
end
private
def groups_user_can_read_epics(groups)
DeclarativePolicy.user_scope do
groups.select { |g| Ability.allowed?(current_user, :read_epic, g) }
end
end end
end end
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
= link_to epic.title, epic_path(epic) = link_to epic.title, epic_path(epic)
.issuable-info .issuable-info
%span.issuable-reference %span.issuable-reference
-# TODO: Use to_reference = epic.to_reference(@group)
= "&#{epic.iid}"
%span.issuable-authored.hidden-xs %span.issuable-authored.hidden-xs
&middot; &middot;
opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')}
......
...@@ -40,7 +40,7 @@ module API ...@@ -40,7 +40,7 @@ module API
success Entities::Epic success Entities::Epic
end end
get ':id/-/epics' do get ':id/-/epics' do
present user_group.epics, with: Entities::Epic present EpicsFinder.new(current_user, group_id: user_group.id).execute, with: Entities::Epic
end end
desc 'Get details of an epic' do desc 'Get details of an epic' do
......
...@@ -44,7 +44,7 @@ describe EpicsFinder do ...@@ -44,7 +44,7 @@ describe EpicsFinder do
end end
end end
context 'wtih correct params' do context 'with correct params' do
before do before do
group.add_developer(search_user) group.add_developer(search_user)
end end
...@@ -79,9 +79,14 @@ describe EpicsFinder do ...@@ -79,9 +79,14 @@ describe EpicsFinder do
end end
end end
context 'by iids' do context 'when subgroups are supported', :nested_groups do
it 'returns all epics by the given iids' do let(:subgroup) { create(:group, :private, parent: group) }
expect(epics(iids: [epic1.iid, epic3.iid])).to contain_exactly(epic1, epic3) let(:subgroup2) { create(:group, :private, parent: subgroup) }
let!(:subepic1) { create(:epic, group: subgroup) }
let!(:subepic2) { create(:epic, group: subgroup2) }
it 'returns all epics that belong to the given group and its subgroups' do
expect(epics).to contain_exactly(epic1, epic2, epic3, subepic1, subepic2)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment