Commit 59a58038 authored by Sean McGivern's avatar Sean McGivern

Merge branch '1698-add-removed-params-from-v3-projects-api' into 'master'

Re-add removed params from projects and issues V3 API

Closes #1698

See merge request !1209
parents 0a108ab1 434e5d8d
---
title: Re-add removed params from projects and issues V3 API
merge_request: 1209
author:
...@@ -45,6 +45,8 @@ module API ...@@ -45,6 +45,8 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names' optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :due_date, type: String, desc: 'Date time string in the format YEAR-MONTH-DAY' optional :due_date, type: String, desc: 'Date time string in the format YEAR-MONTH-DAY'
optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential' optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential'
# Gitlab-EE specific
optional :weight, type: Integer, values: 0..9, desc: 'The weight of the issue'
end end
end end
...@@ -169,7 +171,8 @@ module API ...@@ -169,7 +171,8 @@ module API
optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue' optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
use :issue_params use :issue_params
at_least_one_of :title, :description, :assignee_id, :milestone_id, at_least_one_of :title, :description, :assignee_id, :milestone_id,
:labels, :created_at, :due_date, :confidential, :state_event :labels, :created_at, :due_date, :confidential, :state_event,
:weight
end end
put ':id/issues/:issue_id' do put ':id/issues/:issue_id' do
issue = user_project.issues.find(params.delete(:issue_id)) issue = user_project.issues.find(params.delete(:issue_id))
......
...@@ -25,6 +25,10 @@ module API ...@@ -25,6 +25,10 @@ module API
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access' optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
optional :only_allow_merge_if_build_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :only_allow_merge_if_build_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
# EE-specific
optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins'
optional :approvals_before_merge, type: Integer, desc: 'How many approvers should approve merge request by default'
end end
def map_public_to_visibility_level(attrs) def map_public_to_visibility_level(attrs)
...@@ -287,7 +291,9 @@ module API ...@@ -287,7 +291,9 @@ module API
:lfs_enabled, :public, :visibility_level, :public_builds, :lfs_enabled, :public, :visibility_level, :public_builds,
:request_access_enabled, :only_allow_merge_if_build_succeeds, :request_access_enabled, :only_allow_merge_if_build_succeeds,
:only_allow_merge_if_all_discussions_are_resolved, :path, :only_allow_merge_if_all_discussions_are_resolved, :path,
:default_branch :default_branch,
## EE-specific
:repository_storage, :approvals_before_merge
end end
put ':id' do put ':id' do
authorize_admin_project authorize_admin_project
......
...@@ -634,6 +634,7 @@ describe API::V3::Issues, api: true do ...@@ -634,6 +634,7 @@ describe API::V3::Issues, api: true do
expect(json_response['assignee']).to be_a Hash expect(json_response['assignee']).to be_a Hash
expect(json_response['author']).to be_a Hash expect(json_response['author']).to be_a Hash
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
expect(json_response['weight']).to be_nil
end end
it "returns a project issue by id" do it "returns a project issue by id" do
...@@ -717,13 +718,14 @@ describe API::V3::Issues, api: true do ...@@ -717,13 +718,14 @@ describe API::V3::Issues, api: true do
describe "POST /projects/:id/issues" do describe "POST /projects/:id/issues" do
it 'creates a new project issue' do it 'creates a new project issue' do
post v3_api("/projects/#{project.id}/issues", user), post v3_api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2' title: 'new issue', labels: 'label, label2', weight: 3
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new issue') expect(json_response['title']).to eq('new issue')
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
expect(json_response['labels']).to eq(['label', 'label2']) expect(json_response['labels']).to eq(['label', 'label2'])
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
expect(json_response['weight']).to eq(3)
end end
it 'creates a new confidential project issue' do it 'creates a new confidential project issue' do
...@@ -1093,6 +1095,38 @@ describe API::V3::Issues, api: true do ...@@ -1093,6 +1095,38 @@ describe API::V3::Issues, api: true do
end end
end end
describe 'PUT /projects/:id/issues/:issue_id to update weight' do
it 'updates an issue with no weight' do
put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), weight: 5
expect(response).to have_http_status(200)
expect(json_response['weight']).to eq(5)
end
it 'removes a weight from an issue' do
weighted_issue = create(:issue, project: project, weight: 2)
put v3_api("/projects/#{project.id}/issues/#{weighted_issue.id}", user), weight: nil
expect(response).to have_http_status(200)
expect(json_response['weight']).to be_nil
end
it 'returns 400 if weight is less than minimum weight' do
put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), weight: -1
expect(response).to have_http_status(400)
expect(json_response['error']).to eq('weight does not have a valid value')
end
it 'returns 400 if weight is more than maximum weight' do
put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), weight: 10
expect(response).to have_http_status(400)
expect(json_response['error']).to eq('weight does not have a valid value')
end
end
describe "DELETE /projects/:id/issues/:issue_id" do describe "DELETE /projects/:id/issues/:issue_id" do
it "rejects a non member from deleting an issue" do it "rejects a non member from deleting an issue" do
delete v3_api("/projects/#{project.id}/issues/#{issue.id}", non_member) delete v3_api("/projects/#{project.id}/issues/#{issue.id}", non_member)
......
...@@ -1195,6 +1195,15 @@ describe API::V3::Projects, api: true do ...@@ -1195,6 +1195,15 @@ describe API::V3::Projects, api: true do
expect(json_response['request_access_enabled']).to eq(false) expect(json_response['request_access_enabled']).to eq(false)
end end
it 'updates approvals_before_merge' do
project_param = { approvals_before_merge: 3 }
put v3_api("/projects/#{project.id}", user), project_param
expect(response).to have_http_status(200)
expect(json_response['approvals_before_merge']).to eq(3)
end
it 'updates path & name to existing path & name in different namespace' do it 'updates path & name to existing path & name in different namespace' do
project_param = { path: project4.path, name: project4.name } project_param = { path: project4.path, name: project4.name }
put v3_api("/projects/#{project3.id}", user), project_param put v3_api("/projects/#{project3.id}", user), project_param
......
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