add a uniq constraints on issues and mrs labels
This commit is contained in:
parent
e5aa2d8824
commit
5e10b61129
|
@ -113,7 +113,7 @@ class IssuableBaseService < BaseService
|
|||
new_label_ids -= remove_label_ids if remove_label_ids
|
||||
end
|
||||
|
||||
new_label_ids
|
||||
new_label_ids.uniq
|
||||
end
|
||||
|
||||
def available_labels
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: add a uniq constraints on issues and mrs labels
|
||||
merge_request: 25435
|
||||
author: Antoine Huret
|
||||
type: fixed
|
|
@ -138,6 +138,20 @@ describe Issues::CreateService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when duplicate label titles are given' do
|
||||
let(:label) { create(:label, project: project) }
|
||||
|
||||
let(:opts) do
|
||||
{ title: 'Title',
|
||||
description: 'Description',
|
||||
labels: [label.title, label.title] }
|
||||
end
|
||||
|
||||
it 'assigns the label once' do
|
||||
expect(issue.labels).to contain_exactly(label)
|
||||
end
|
||||
end
|
||||
|
||||
it 'executes issue hooks when issue is not confidential' do
|
||||
opts = { title: 'Title', description: 'Description', confidential: false }
|
||||
|
||||
|
|
|
@ -592,6 +592,16 @@ describe Issues::UpdateService, :mailer do
|
|||
expect(result.label_ids).not_to include(label.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when duplicate label titles are given' do
|
||||
let(:params) do
|
||||
{ labels: [label3.title, label3.title] }
|
||||
end
|
||||
|
||||
it 'assigns the label once' do
|
||||
expect(result.labels).to contain_exactly(label3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'updating asssignee_id' do
|
||||
|
|
Loading…
Reference in New Issue