Return unique issues when using multiple labels
This ensures that IssuableFinder returns a collection of unique issues, even when filtering issues using multiple labels.
This commit is contained in:
parent
42e0625dfb
commit
dc13f7c31d
2 changed files with 19 additions and 1 deletions
|
@ -278,7 +278,9 @@ class IssuableFinder
|
|||
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
|
||||
|
||||
def label_names
|
||||
|
|
|
@ -62,6 +62,22 @@ describe IssuesFinder do
|
|||
expect(issues).to eq([issue2])
|
||||
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
|
||||
params = { scope: "all", label_name: Label::None.title, state: 'opened' }
|
||||
issues = IssuesFinder.new(user, params).execute
|
||||
|
|
Loading…
Reference in a new issue