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
This commit is contained in:
Stan Hu 2016-10-23 16:46:21 -07:00
parent add3a2c443
commit ddafea060d
3 changed files with 11 additions and 0 deletions

View File

@ -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)
## 8.13.1 (unreleased)
- Fix bug where labels would be assigned to issues that were moved
- Fix error in generating labels
- Fix reply-by-email not working due to queue name mismatch
- Fixed hidden pipeline graph on commit and MR page !6895

View File

@ -35,6 +35,10 @@ class LabelsFinder < UnionFinder
end
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
end

View File

@ -64,6 +64,12 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2]
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