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
## 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
......
......@@ -9,7 +9,8 @@ milestones.
## Creating an epic
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. Click the **New epic** button at the top right
......
......@@ -10,7 +10,6 @@ class EpicsFinder < IssuableFinder
items = by_created_at(items)
items = by_search(items)
items = by_author(items)
items = by_iids(items)
sort(items)
end
......@@ -37,6 +36,16 @@ class EpicsFinder < IssuableFinder
end
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
......@@ -7,8 +7,7 @@
= link_to epic.title, epic_path(epic)
.issuable-info
%span.issuable-reference
-# TODO: Use to_reference
= "&#{epic.iid}"
= epic.to_reference(@group)
%span.issuable-authored.hidden-xs
&middot;
opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')}
......
......@@ -40,7 +40,7 @@ module API
success Entities::Epic
end
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
desc 'Get details of an epic' do
......
......@@ -44,7 +44,7 @@ describe EpicsFinder do
end
end
context 'wtih correct params' do
context 'with correct params' do
before do
group.add_developer(search_user)
end
......@@ -79,9 +79,14 @@ describe EpicsFinder do
end
end
context 'by iids' do
it 'returns all epics by the given iids' do
expect(epics(iids: [epic1.iid, epic3.iid])).to contain_exactly(epic1, epic3)
context 'when subgroups are supported', :nested_groups do
let(:subgroup) { create(:group, :private, parent: group) }
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
......
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