Commit a30eebea authored by Sean McGivern's avatar Sean McGivern

Merge branch 'uniq-constraints-on-issue/mr-labels' into 'master'

add a uniq constraints on issues and mrs labels

See merge request gitlab-org/gitlab-ce!25435
parents e5aa2d88 5e10b611
......@@ -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
......
---
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
......
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