Multiple issue assignee: CE restriction for multiple assignees
This commit is contained in:
parent
9c0f2485b5
commit
0cfe35f727
|
@ -24,6 +24,9 @@ module Issues
|
|||
def filter_assignee(issuable)
|
||||
return if params[:assignee_ids].blank?
|
||||
|
||||
# The number of assignees is limited by one for GitLab CE
|
||||
params[:assignee_ids].slice!(0, 1)
|
||||
|
||||
assignee_ids = params[:assignee_ids].select { |assignee_id| assignee_can_read?(issuable, assignee_id) }
|
||||
|
||||
if params[:assignee_ids].map(&:to_s) == [IssuableFinder::NONE]
|
||||
|
|
|
@ -772,6 +772,17 @@ describe API::Issues do
|
|||
end
|
||||
end
|
||||
|
||||
context 'CE restrictions' do
|
||||
it 'creates a new project issue with no more than one assignee' do
|
||||
post api("/projects/#{project.id}/issues", user),
|
||||
title: 'new issue', assignee_ids: [user2.id, guest.id]
|
||||
|
||||
expect(response).to have_http_status(201)
|
||||
expect(json_response['title']).to eq('new issue')
|
||||
expect(json_response['assignees'].count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates a new project issue' do
|
||||
post api("/projects/#{project.id}/issues", user),
|
||||
title: 'new issue', labels: 'label, label2', weight: 3,
|
||||
|
@ -1111,6 +1122,17 @@ describe API::Issues do
|
|||
|
||||
expect(json_response['assignees'].first['name']).to eq(user2.name)
|
||||
end
|
||||
|
||||
context 'CE restrictions' do
|
||||
it 'updates an issue with several assignee but only one has been applied' do
|
||||
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
|
||||
assignee_ids: [user2.id, guest.id]
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(json_response['assignees'].size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT /projects/:id/issues/:issue_iid to update labels' do
|
||||
|
|
|
@ -220,4 +220,31 @@ describe Notes::SlashCommandsService, services: true do
|
|||
let(:note) { build(:note_on_commit, project: project) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'CE restriction for issue assignees' do
|
||||
describe '/assign' do
|
||||
let(:project) { create(:empty_project) }
|
||||
let(:master) { create(:user).tap { |u| project.team << [u, :master] } }
|
||||
let(:assignee) { create(:user) }
|
||||
let(:master) { create(:user) }
|
||||
let(:service) { described_class.new(project, master) }
|
||||
let(:note) { create(:note_on_issue, note: note_text, project: project) }
|
||||
|
||||
let(:note_text) do
|
||||
%(/assign @#{assignee.username} @#{master.username}\n")
|
||||
end
|
||||
|
||||
before do
|
||||
project.team << [master, :master]
|
||||
project.team << [assignee, :master]
|
||||
end
|
||||
|
||||
it 'adds only one assignee from the list' do
|
||||
content, command_params = service.extract_commands(note)
|
||||
service.execute(command_params, note)
|
||||
|
||||
expect(note.noteable.assignees.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue