Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-08-04 14:09:10 +0300
committerZ.J. van de Weg <zegerjan@gitlab.com>2016-08-04 17:55:20 +0300
commit460065b743a5f28d92bda71b0e778b01cd369d80 (patch)
tree04f8b0a7a3d4b3da1a5e204ff5d0f81770f5fe58 /lib/api/deploy_keys.rb
parent2b6bd6a33f765175222cdb88cd927e420864a236 (diff)
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.rb11
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