Merge branch '30021-api-deploy_keys-can_push-is-not-honoured' into 'master'

Enable creation of deploy keys with write access via the API

Closes #30021

See merge request !10488
This commit is contained in:
Rémy Coutable 2017-04-06 10:11:31 +00:00
commit d7e3f2322f
4 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
title: Enable creation of deploy keys with write access via the API
merge_request:
author:

View File

@ -47,6 +47,7 @@ module API
params do
requires :key, type: String, desc: 'The new deploy key'
requires :title, type: String, desc: 'The name of the deploy key'
optional :can_push, type: Boolean, desc: "Can deploy key push to the project's repository"
end
post ":id/deploy_keys" do
params[:key].strip!

View File

@ -23,5 +23,9 @@ FactoryGirl.define do
factory :another_deploy_key, class: 'DeployKey' do
end
end
factory :write_access_key, class: 'DeployKey' do
can_push true
end
end
end

View File

@ -108,6 +108,15 @@ describe API::DeployKeys, api: true do
expect(response).to have_http_status(201)
end
it 'accepts can_push parameter' do
key_attrs = attributes_for :write_access_key
post api("/projects/#{project.id}/deploy_keys", admin), key_attrs
expect(response).to have_http_status(201)
expect(json_response['can_push']).to eq(true)
end
end
describe 'DELETE /projects/:id/deploy_keys/:key_id' do