BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7e47a828
Commit
7e47a828
authored
Aug 08, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace EnableDeployKeyService under Projects
parent
81e839f4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
13 deletions
+17
-13
deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+1
-1
enable_deploy_key_service.rb
app/services/projects/enable_deploy_key_service.rb
+12
-9
deploy_keys.rb
lib/api/deploy_keys.rb
+2
-1
enable_deploy_key_service_spec.rb
spec/services/projects/enable_deploy_key_service_spec.rb
+2
-2
No files found.
app/controllers/projects/deploy_keys_controller.rb
View file @
7e47a828
...
...
@@ -27,7 +27,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def
enable
EnableDeployKeyService
.
new
(
@project
,
current_user
,
params
).
execute
Projects
::
EnableDeployKeyService
.
new
(
@project
,
current_user
,
params
).
execute
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
@project
)
end
...
...
app/services/enable_deploy_key_service.rb
→
app/services/
projects/
enable_deploy_key_service.rb
View file @
7e47a828
class
EnableDeployKeyService
<
BaseService
def
execute
key
=
accessible_keys
.
find_by
(
id:
params
[
:key_id
]
||
params
[
:id
])
module
Projects
class
EnableDeployKeyService
<
BaseService
def
execute
key
=
accessible_keys
.
find_by
(
id:
params
[
:key_id
]
||
params
[
:id
])
return
unless
key
project
.
deploy_keys
<<
key
if
key
key
end
project
.
deploy_keys
<<
key
key
end
private
private
def
accessible_keys
current_user
.
accessible_deploy_keys
def
accessible_keys
current_user
.
accessible_deploy_keys
end
end
end
lib/api/deploy_keys.rb
View file @
7e47a828
...
...
@@ -76,7 +76,8 @@ module API
requires
:key_id
,
type:
Integer
,
desc:
'The ID of the deploy key'
end
post
":id/
#{
path
}
/:key_id/enable"
do
key
=
EnableDeployKeyService
.
new
(
user_project
,
current_user
,
declared
(
params
)).
execute
key
=
::
Projects
::
EnableDeployKeyService
.
new
(
user_project
,
current_user
,
declared
(
params
)).
execute
if
key
present
key
,
with:
Entities
::
SSHKey
...
...
spec/services/enable_deploy_key_service_spec.rb
→
spec/services/
projects/
enable_deploy_key_service_spec.rb
View file @
7e47a828
require
'spec_helper'
describe
EnableDeployKeyService
,
services:
true
do
describe
Projects
::
EnableDeployKeyService
,
services:
true
do
let
(
:deploy_key
)
{
create
(
:deploy_key
,
public:
true
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
project
.
creator
}
...
...
@@ -22,6 +22,6 @@ describe EnableDeployKeyService, services: true do
end
def
service
EnableDeployKeyService
.
new
(
project
,
user
,
params
)
Projects
::
EnableDeployKeyService
.
new
(
project
,
user
,
params
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment