summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2018-01-15 14:24:16 +0200
committerValery Sizov <valery@gitlab.com>2018-01-15 14:24:16 +0200
commit1b1cc6fb14be2d8c8d24ddd446030d2470bf9527 (patch)
tree2aa65ce13efce678fda4862df24290f3f534ec0a
parentcedbf9c8b4a650a5a62adfd6b62df81c08896806 (diff)
downloadgitlab-ce-1b1cc6fb14be2d8c8d24ddd446030d2470bf9527.tar.gz
[API] Fix creating issue when assignee_id is empty42025-fix-issue-api
see https://gitlab.com/gitlab-org/gitlab-ce/issues/42025
-rw-r--r--changelogs/unreleased/42025-fix-issue-api.yml5
-rw-r--r--lib/api/helpers/common_helpers.rb6
-rw-r--r--spec/requests/api/issues_spec.rb9
3 files changed, 18 insertions, 2 deletions
diff --git a/changelogs/unreleased/42025-fix-issue-api.yml b/changelogs/unreleased/42025-fix-issue-api.yml
new file mode 100644
index 00000000000..abb83bb2fad
--- /dev/null
+++ b/changelogs/unreleased/42025-fix-issue-api.yml
@@ -0,0 +1,5 @@
+---
+title: "[API] Fix creating issue when assignee_id is empty"
+merge_request:
+author:
+type: fixed
diff --git a/lib/api/helpers/common_helpers.rb b/lib/api/helpers/common_helpers.rb
index 322624c6092..9993caa5249 100644
--- a/lib/api/helpers/common_helpers.rb
+++ b/lib/api/helpers/common_helpers.rb
@@ -3,8 +3,10 @@ module API
module CommonHelpers
def convert_parameters_from_legacy_format(params)
params.tap do |params|
- if params[:assignee_id].present?
- params[:assignee_ids] = [params.delete(:assignee_id)]
+ assignee_id = params.delete(:assignee_id)
+
+ if assignee_id.present?
+ params[:assignee_ids] = [assignee_id]
end
end
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 320217f2032..43218755f4f 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -847,6 +847,15 @@ describe API::Issues, :mailer do
expect(json_response['assignee']['name']).to eq(user2.name)
expect(json_response['assignees'].first['name']).to eq(user2.name)
end
+
+ it 'creates a new project issue when assignee_id is empty' do
+ post api("/projects/#{project.id}/issues", user),
+ title: 'new issue', assignee_id: ''
+
+ expect(response).to have_gitlab_http_status(201)
+ expect(json_response['title']).to eq('new issue')
+ expect(json_response['assignee']).to be_nil
+ end
end
context 'single assignee restrictions' do