diff options
author | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-06-15 16:05:24 -0600 |
---|---|---|
committer | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-06-15 16:05:24 -0600 |
commit | 609324e157480fb2b489d77a530c205eb5b5dce4 (patch) | |
tree | cdd8cbe995a81822b22ed177e8614d1b0405f37a | |
parent | edfa2e3fb673412272e8bc9cdbfa2e3a86a9f21f (diff) | |
download | gitlab-ce-api-mr-put-labels.tar.gz |
PUT MergeRequest API endpoint - accept labels as an arrayapi-mr-put-labels
-rw-r--r-- | lib/api/merge_requests.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index af7d2471b34..8b47f3a8fb8 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -160,7 +160,7 @@ module API optional :description, type: String, desc: 'The description of the merge request' optional :assignee_id, type: Integer, desc: 'The ID of a user to assign the merge request' optional :milestone_id, type: Integer, desc: 'The ID of a milestone to assign the merge request' - optional :labels, type: String, desc: 'Comma-separated list of label names' + optional :labels, type: String, coerce_with: ->(val) { val.is_a?(Array) ? val.join(', ') : val }, desc: 'Comma-separated list of label names' optional :remove_source_branch, type: Boolean, desc: 'Remove source branch when merging' optional :allow_collaboration, type: Boolean, desc: 'Allow commits from members who can merge to the target branch' optional :allow_maintainer_to_push, type: Boolean, as: :allow_collaboration, desc: '[deprecated] See allow_collaboration' diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index d4ebfc3f782..4c2c05b4fcd 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -903,6 +903,19 @@ describe API::MergeRequests do expect(json_response['labels']).to include '&' end + it 'also accepts labels as an array' do + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), + title: 'new issue', + labels: ['label', 'label?', 'label&foo', '?', '&'] + + expect(response.status).to eq(200) + expect(json_response['labels']).to include 'label' + expect(json_response['labels']).to include 'label?' + expect(json_response['labels']).to include 'label&foo' + expect(json_response['labels']).to include '?' + expect(json_response['labels']).to include '&' + end + it 'does not update state when title is empty' do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), state_event: 'close', title: nil |