Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
fa7ed15d
Commit
fa7ed15d
authored
Dec 18, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Projects::DeployKeysController EE-ready
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
becfb662
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+1
-1
app/services/deploy_keys/create_service.rb
app/services/deploy_keys/create_service.rb
+1
-1
spec/controllers/projects/deploy_keys_controller_spec.rb
spec/controllers/projects/deploy_keys_controller_spec.rb
+35
-1
No files found.
app/controllers/projects/deploy_keys_controller.rb
View file @
fa7ed15d
...
@@ -24,7 +24,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
...
@@ -24,7 +24,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
end
def
create
def
create
@key
=
DeployKeys
::
CreateService
.
new
(
current_user
,
create_params
).
execute
@key
=
DeployKeys
::
CreateService
.
new
(
current_user
,
create_params
).
execute
(
project:
@project
)
unless
@key
.
valid?
unless
@key
.
valid?
flash
[
:alert
]
=
@key
.
errors
.
full_messages
.
join
(
', '
).
html_safe
flash
[
:alert
]
=
@key
.
errors
.
full_messages
.
join
(
', '
).
html_safe
...
...
app/services/deploy_keys/create_service.rb
View file @
fa7ed15d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
module
DeployKeys
module
DeployKeys
class
CreateService
<
Keys
::
BaseService
class
CreateService
<
Keys
::
BaseService
def
execute
def
execute
(
project:
nil
)
DeployKey
.
create
(
params
.
merge
(
user:
user
))
DeployKey
.
create
(
params
.
merge
(
user:
user
))
end
end
end
end
...
...
spec/controllers/projects/deploy_keys_controller_spec.rb
View file @
fa7ed15d
...
@@ -16,7 +16,7 @@ describe Projects::DeployKeysController do
...
@@ -16,7 +16,7 @@ describe Projects::DeployKeysController do
end
end
context
'when html requested'
do
context
'when html requested'
do
it
'redirects to
blob
'
do
it
'redirects to
project settings with the correct anchor
'
do
get
:index
,
params:
params
get
:index
,
params:
params
expect
(
response
).
to
redirect_to
(
project_settings_repository_path
(
project
,
anchor:
'js-deploy-keys-settings'
))
expect
(
response
).
to
redirect_to
(
project_settings_repository_path
(
project
,
anchor:
'js-deploy-keys-settings'
))
...
@@ -60,6 +60,40 @@ describe Projects::DeployKeysController do
...
@@ -60,6 +60,40 @@ describe Projects::DeployKeysController do
end
end
end
end
describe
'POST create'
do
def
create_params
(
title
=
'my-key'
)
{
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
deploy_key:
{
title:
title
,
key:
attributes_for
(
:deploy_key
)[
:key
],
deploy_keys_projects_attributes:
{
'0'
=>
{
can_push:
'1'
}
}
}
}
end
it
'creates a new deploy key for the project'
do
expect
{
post
:create
,
params:
create_params
}.
to
change
(
project
.
deploy_keys
,
:count
).
by
(
1
)
expect
(
response
).
to
redirect_to
(
project_settings_repository_path
(
project
,
anchor:
'js-deploy-keys-settings'
))
end
it
'redirects to project settings with the correct anchor'
do
post
:create
,
params:
create_params
expect
(
response
).
to
redirect_to
(
project_settings_repository_path
(
project
,
anchor:
'js-deploy-keys-settings'
))
end
context
'when the deploy key is invalid'
do
it
'shows an alert with the validations errors'
do
post
:create
,
params:
create_params
(
nil
)
expect
(
flash
[
:alert
]).
to
eq
(
"Title can't be blank, Deploy keys projects deploy key title can't be blank"
)
end
end
end
describe
'/enable/:id'
do
describe
'/enable/:id'
do
let
(
:deploy_key
)
{
create
(
:deploy_key
)
}
let
(
:deploy_key
)
{
create
(
:deploy_key
)
}
let
(
:project2
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
...
...
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