Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-05-05 18:55:16 +0300
committerValery Sizov <valery@gitlab.com>2017-05-05 18:55:16 +0300
commit0cfe35f7279e7b6618c10be91908c29cd7ab110a (patch)
tree69b9ef3167b78ce42e6178358e05d90e78856840
parent9c0f2485b5d7fed5b538313e5bf867110273c004 (diff)
Multiple issue assignee: CE restriction for multiple assignees
-rw-r--r--app/services/issues/base_service.rb3
-rw-r--r--spec/requests/api/issues_spec.rb22
-rw-r--r--spec/services/notes/slash_commands_service_spec.rb27
3 files changed, 52 insertions, 0 deletions
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index eedbfa724ff..bcd196bfa21 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -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]
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 9b7b5798b71..da2b56c040b 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -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
diff --git a/spec/services/notes/slash_commands_service_spec.rb b/spec/services/notes/slash_commands_service_spec.rb
index 0edcc50ed7b..b99f01162ee 100644
--- a/spec/services/notes/slash_commands_service_spec.rb
+++ b/spec/services/notes/slash_commands_service_spec.rb
@@ -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