Commit 5e10b611 authored by Antoine Huret's avatar Antoine Huret Committed by Sean McGivern

add a uniq constraints on issues and mrs labels

parent e5aa2d88
...@@ -113,7 +113,7 @@ class IssuableBaseService < BaseService ...@@ -113,7 +113,7 @@ class IssuableBaseService < BaseService
new_label_ids -= remove_label_ids if remove_label_ids new_label_ids -= remove_label_ids if remove_label_ids
end end
new_label_ids new_label_ids.uniq
end end
def available_labels def available_labels
......
---
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 ...@@ -138,6 +138,20 @@ describe Issues::CreateService do
end end
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 it 'executes issue hooks when issue is not confidential' do
opts = { title: 'Title', description: 'Description', confidential: false } opts = { title: 'Title', description: 'Description', confidential: false }
......
...@@ -592,6 +592,16 @@ describe Issues::UpdateService, :mailer do ...@@ -592,6 +592,16 @@ describe Issues::UpdateService, :mailer do
expect(result.label_ids).not_to include(label.id) expect(result.label_ids).not_to include(label.id)
end end
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 end
context 'updating asssignee_id' do context 'updating asssignee_id' do
......
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