diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-04 13:09:10 +0200 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-04 16:55:20 +0200 |
commit | 460065b743a5f28d92bda71b0e778b01cd369d80 (patch) | |
tree | 04f8b0a7a3d4b3da1a5e204ff5d0f81770f5fe58 /lib/api/deploy_keys.rb | |
parent | 2b6bd6a33f765175222cdb88cd927e420864a236 (diff) | |
download | gitlab-ce-460065b743a5f28d92bda71b0e778b01cd369d80.tar.gz |
Move deploy_key tests to deploy_key_spec.rb
Also, fix the failing test in the process
Diffstat (limited to 'lib/api/deploy_keys.rb')
-rw-r--r-- | lib/api/deploy_keys.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 6a0be345667..52f89373ad3 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -38,15 +38,16 @@ module API present key, with: Entities::SSHKey end + # TODO: for 9.0 we should check if params are there with the params block + # grape provides, at this point we'd change behaviour so we can't + # Behaviour now if you don't provide all required params: it renders a + # validation error or two. desc 'Add new deploy key to currently authenticated user' do success Entities::SSHKey end - params do - requires :key, type: String, desc: "The new deploy key" - requires :title, type: String, desc: 'The title to identify the key from' - end post ":id/#{path}" do - attrs = declared(params, include_parent_namespaces: false).to_h + attrs = attributes_for_keys [:title, :key] + attrs[:key].strip! if attrs[:key] key = user_project.deploy_keys.find_by(key: attrs[:key]) present key, with: Entities::SSHKey if key |