Commit ddafea06 authored by Stan Hu's avatar Stan Hu

Fix bug where labels would be assigned to issues that were moved

If you attempt to move an issue from one project to another and leave
labels blank, LabelsFinder would assign all labels in the new project
to that issue. The issue is that :title is passed along to the Finder,
but since it appears empty no filtering is done. As a result, all
labels in the group are returned. This fix handles that case.

Closes #23668
parent add3a2c4
...@@ -16,6 +16,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -16,6 +16,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Refactor email, use setter method instead AR callbacks for email attribute (Semyon Pupkov) - Refactor email, use setter method instead AR callbacks for email attribute (Semyon Pupkov)
## 8.13.1 (unreleased) ## 8.13.1 (unreleased)
- Fix bug where labels would be assigned to issues that were moved
- Fix error in generating labels - Fix error in generating labels
- Fix reply-by-email not working due to queue name mismatch - Fix reply-by-email not working due to queue name mismatch
- Fixed hidden pipeline graph on commit and MR page !6895 - Fixed hidden pipeline graph on commit and MR page !6895
......
...@@ -35,6 +35,10 @@ class LabelsFinder < UnionFinder ...@@ -35,6 +35,10 @@ class LabelsFinder < UnionFinder
end end
def with_title(items) def with_title(items)
# Match no labels if an empty title is supplied to avoid matching all
# labels (e.g. when an issue is moved)
return Label.none if params[:title] && params[:title].empty?
items = items.where(title: title) if title items = items.where(title: title) if title
items items
end end
......
...@@ -64,6 +64,12 @@ describe LabelsFinder do ...@@ -64,6 +64,12 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2] expect(finder.execute).to eq [group_label_2]
end end
it 'returns no labels if empty titles are supplied' do
finder = described_class.new(user, title: [])
expect(finder.execute).to be_empty
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