提交 af4d16d9 编写于 作者: S Stan Hu

Allow the use of params[:name] when filtering labels

上级 7c0ccbaa
......@@ -37,10 +37,13 @@ class LabelsFinder < UnionFinder
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?
return items.none if raw_title && raw_title.empty?
items = items.where(title: title) if title
items
if title
items = items.where(title: title)
else
items
end
end
def group_id
......@@ -59,6 +62,10 @@ class LabelsFinder < UnionFinder
params[:title].presence || params[:name].presence
end
def raw_title
params[:title] || params[:name]
end
def project
return @project if defined?(@project)
......
......@@ -65,11 +65,23 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2]
end
it 'returns label with title alias' do
finder = described_class.new(user, name: 'Group Label 2')
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
it 'returns no labels if empty names are supplied' do
finder = described_class.new(user, name: [])
expect(finder.execute).to be_empty
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册