Commit dc13f7c3 authored by Yorick Peterse's avatar Yorick Peterse Committed by Jacob Schatz

Return unique issues when using multiple labels

This ensures that IssuableFinder returns a collection of unique issues,
even when filtering issues using multiple labels.
parent 42e0625d
...@@ -278,7 +278,9 @@ class IssuableFinder ...@@ -278,7 +278,9 @@ class IssuableFinder
end end
end end
items # When filtering by multiple labels we may end up duplicating issues (if one
# has multiple labels). This ensures we only return unique issues.
items.distinct
end end
def label_names def label_names
......
...@@ -62,6 +62,22 @@ describe IssuesFinder do ...@@ -62,6 +62,22 @@ describe IssuesFinder do
expect(issues).to eq([issue2]) expect(issues).to eq([issue2])
end end
it 'returns unique issues when filtering by multiple labels' do
label2 = create(:label, project: project2)
create(:label_link, label: label2, target: issue2)
params = {
scope: 'all',
label_name: [label.title, label2.title].join(','),
state: 'opened'
}
issues = IssuesFinder.new(user, params).execute
expect(issues).to eq([issue2])
end
it 'should filter by no label name' do it 'should filter by no label name' do
params = { scope: "all", label_name: Label::None.title, state: 'opened' } params = { scope: "all", label_name: Label::None.title, state: 'opened' }
issues = IssuesFinder.new(user, params).execute issues = IssuesFinder.new(user, params).execute
......
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