Commit a8f201f0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '195180-filter-issues-by-subepic' into 'master'

Include subepics in IssuesFinder if requested

See merge request gitlab-org/gitlab!24706
parents 4a6eab3b 22113004
...@@ -87,13 +87,21 @@ module EE ...@@ -87,13 +87,21 @@ module EE
params[:epic_id].to_s.downcase == ::IssuesFinder::FILTER_NONE params[:epic_id].to_s.downcase == ::IssuesFinder::FILTER_NONE
end end
def epics
if params[:include_subepics]
::Gitlab::ObjectHierarchy.new(::Epic.for_ids(params[:epic_id])).base_and_descendants.select(:id)
else
params[:epic_id]
end
end
def by_epic(items) def by_epic(items)
return items unless by_epic? return items unless by_epic?
if filter_by_no_epic? if filter_by_no_epic?
items.no_epic items.no_epic
else else
items.in_epics(params[:epic_id]) items.in_epics(epics)
end end
end end
end end
......
...@@ -97,8 +97,20 @@ describe IssuesFinder do ...@@ -97,8 +97,20 @@ describe IssuesFinder do
context 'filter issues by epic' do context 'filter issues by epic' do
let(:params) { { epic_id: epic_1.id } } let(:params) { { epic_id: epic_1.id } }
it 'returns all issues in the epic, subepic issues excluded' do context 'when include_subepics param is not included' do
expect(issues).to contain_exactly(issue_1) it 'returns all issues in the epic, subepic issues excluded' do
expect(issues).to contain_exactly(issue_1)
end
end
context 'when include_subepics param is set to true' do
before do
params[:include_subepics] = true
end
it 'returns all issues in the epic including subepic issues' do
expect(issues).to contain_exactly(issue_1, issue_subepic)
end
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