Commit 64ed7069 authored by Robert Schilling's avatar Robert Schilling

Incorporate review feedback

Use shared examples for issues and merge requests
rather than a loop creating common specs.
parent 6b2673bc
...@@ -637,7 +637,7 @@ Example response: ...@@ -637,7 +637,7 @@ Example response:
## Bulk update issues ## Bulk update issues
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21368) in GitLab 11.8. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21368) in GitLab 11.9.
Update multiple issues using a single API call. Returns the number of successfully updated issues. Update multiple issues using a single API call. Returns the number of successfully updated issues.
......
...@@ -958,7 +958,7 @@ Must include at least one non-required attribute from above. ...@@ -958,7 +958,7 @@ Must include at least one non-required attribute from above.
## Bulk update merge requests ## Bulk update merge requests
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21368) in GitLab 11.8. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21368) in GitLab 11.9.
Update multiple merge requests using a single API call. Returns the number of successfully updated merge requests. Update multiple merge requests using a single API call. Returns the number of successfully updated merge requests.
......
...@@ -11,7 +11,7 @@ module API ...@@ -11,7 +11,7 @@ module API
detail 'This feature was introduced in 11.9' detail 'This feature was introduced in 11.9'
end end
params do params do
requires :issuable_ids, type: Array[Integer], desc: "Array or #{issuable.pluralize} IDs to be updates" requires :issuable_ids, type: Array[Integer], desc: "Array of #{issuable.pluralize} IDs to be updated"
optional :state_event, type: String, values: %w(reopen close), desc: 'Reopens or closes a resource' optional :state_event, type: String, values: %w(reopen close), desc: 'Reopens or closes a resource'
optional :milestone_id, type: Integer, desc: 'The milestone ID number' optional :milestone_id, type: Integer, desc: 'The milestone ID number'
optional :add_label_ids, type: Array[Integer], desc: 'IDs of labels to be added' optional :add_label_ids, type: Array[Integer], desc: 'IDs of labels to be added'
...@@ -20,7 +20,7 @@ module API ...@@ -20,7 +20,7 @@ module API
desc: 'Subscribes or unsubscribes from a resource' desc: 'Subscribes or unsubscribes from a resource'
if issuable == 'issue' if issuable == 'issue'
optional :assignee_ids, type: Array[Integer], desc: 'List of assignees IDs' optional :assignee_ids, type: Array[Integer], desc: 'List of assignee IDs'
at_least_one_of :state_event, :milestone_id, :add_label_ids, :remove_label_ids, at_least_one_of :state_event, :milestone_id, :add_label_ids, :remove_label_ids,
:subscription_event, :assignee_ids :subscription_event, :assignee_ids
else else
......
...@@ -3,17 +3,10 @@ ...@@ -3,17 +3,10 @@
require 'spec_helper' require 'spec_helper'
describe API::IssuableBulkUpdate do describe API::IssuableBulkUpdate do
set(:user) { create(:user) } set(:project) { create(:project) }
set(:project) do set(:user) { project.creator }
create(:project, :public, creator_id: user.id, namespace: user.namespace)
end
%w(issue merge_request).each do |issuable|
describe "PUT /projects/:id/#{issuable.pluralize}/bulk_update" do
let(:merge_request_1) { create(:merge_request, source_project: project) }
let(:merge_request_2) { create(:merge_request, :simple, source_project: project) }
let!(:issuables) { issuable == 'issue' ? create_list(:issue, 2, project: project) : [merge_request_1, merge_request_2] }
shared_examples "PUT /projects/:id/:issuable/bulk_update" do |issuable|
def bulk_update(issuable, issuables, params, update_user = user) def bulk_update(issuable, issuables, params, update_user = user)
put api("/projects/#{project.id}/#{issuable.pluralize}/bulk_update", update_user), put api("/projects/#{project.id}/#{issuable.pluralize}/bulk_update", update_user),
params: { issuable_ids: Array(issuables).map(&:id) }.merge(params) params: { issuable_ids: Array(issuables).map(&:id) }.merge(params)
...@@ -148,5 +141,14 @@ describe API::IssuableBulkUpdate do ...@@ -148,5 +141,14 @@ describe API::IssuableBulkUpdate do
end end
end end
end end
it_behaves_like 'PUT /projects/:id/:issuable/bulk_update', 'issue' do
let(:issuables) { create_list(:issue, 2, project: project) }
end
it_behaves_like 'PUT /projects/:id/:issuable/bulk_update', 'merge_request' do
let(:merge_request_1) { create(:merge_request, source_project: project) }
let(:merge_request_2) { create(:merge_request, :simple, source_project: project) }
let(:issuables) { [merge_request_1, merge_request_2] }
end end
end end
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