Commit c60a551a authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '215657-searching-issues-with-epic-any-doesn-t-return-anything' into 'master'

Add issues filter for any epic

See merge request gitlab-org/gitlab!31614
parents e8913e13 a6d265b1
......@@ -55,6 +55,8 @@ module EE
if params.filter_by_no_epic?
items.no_epic
elsif params.filter_by_any_epic?
items.any_epic
else
items.in_epics(params.epics)
end
......
......@@ -14,6 +14,10 @@ module EE
params[:epic_id].to_s.downcase == ::IssuableFinder::Params::FILTER_NONE
end
def filter_by_any_epic?
params[:epic_id].to_s.downcase == ::IssuableFinder::Params::FILTER_ANY
end
def weights?
params[:weight].present? && params[:weight] != ::Issue::WEIGHT_ALL
end
......
......@@ -21,6 +21,7 @@ module EE
scope :order_weight_asc, -> { reorder ::Gitlab::Database.nulls_last_order('weight') }
scope :service_desk, -> { where(author: ::User.support_bot) }
scope :no_epic, -> { left_outer_joins(:epic_issue).where(epic_issues: { epic_id: nil }) }
scope :any_epic, -> { joins(:epic_issue) }
scope :in_epics, ->(epics) do
issue_ids = EpicIssue.where(epic_id: epics).select(:issue_id)
id_in(issue_ids)
......
---
title: Fix issues search to include the epic filter ANY
merge_request: 31614
author:
type: fixed
......@@ -113,6 +113,14 @@ describe IssuesFinder do
end
end
end
context 'filter issues with any epic' do
let(:params) { { epic_id: ::IssuableFinder::Params::FILTER_ANY } }
it 'returns filtered issues' do
expect(issues).to contain_exactly(issue_1, issue_2, issue_subepic)
end
end
end
end
end
......
......@@ -128,6 +128,13 @@ describe Issue do
end
end
describe '.any_epic' do
it 'returns only issues with an epic assigned' do
expect(described_class.count).to eq 3
expect(described_class.any_epic).to eq [epic_issue1.issue, epic_issue2.issue]
end
end
describe '.in_epics' do
it 'returns only issues in selected epics' do
expect(described_class.count).to eq 3
......
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