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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c7bcebd5
Commit
c7bcebd5
authored
Jun 20, 2017
by
Alexander Randa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix edit button for deploy keys available from other projects
parent
5214e507
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
3 deletions
+34
-3
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+2
-2
changelogs/unreleased/33878_fix_edit_deploy_key.yml
changelogs/unreleased/33878_fix_edit_deploy_key.yml
+4
-0
lib/api/deploy_keys.rb
lib/api/deploy_keys.rb
+1
-1
spec/features/projects/settings/repository_settings_spec.rb
spec/features/projects/settings/repository_settings_spec.rb
+17
-0
spec/requests/api/deploy_keys_spec.rb
spec/requests/api/deploy_keys_spec.rb
+10
-0
No files found.
app/controllers/projects/deploy_keys_controller.rb
View file @
c7bcebd5
...
...
@@ -6,7 +6,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
before_action
:authorize_admin_project!
before_action
:authorize_update_deploy_key!
,
only:
[
:edit
,
:update
]
layout
"project_settings"
layout
'project_settings'
def
index
respond_to
do
|
format
|
...
...
@@ -66,7 +66,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
protected
def
deploy_key
@deploy_key
||=
@project
.
deploy_keys
.
find
(
params
[
:id
])
@deploy_key
||=
DeployKey
.
find
(
params
[
:id
])
end
def
create_params
...
...
changelogs/unreleased/33878_fix_edit_deploy_key.yml
0 → 100644
View file @
c7bcebd5
---
title
:
Fix edit button for deploy keys available from other projects
merge_request
:
12301
author
:
Alexander Randa
lib/api/deploy_keys.rb
View file @
c7bcebd5
...
...
@@ -86,7 +86,7 @@ module API
at_least_one_of
:title
,
:can_push
end
put
":id/deploy_keys/:key_id"
do
key
=
user_project
.
deploy_keys
.
find
(
params
.
delete
(
:key_id
))
key
=
DeployKey
.
find
(
params
.
delete
(
:key_id
))
authorize!
(
:update_deploy_key
,
key
)
...
...
spec/features/projects/settings/repository_settings_spec.rb
View file @
c7bcebd5
...
...
@@ -65,6 +65,23 @@ feature 'Repository settings', feature: true do
expect
(
page
).
to
have_content
(
'Write access allowed'
)
end
scenario
'edit a deploy key from projects user has access to'
do
project2
=
create
(
:project_empty_repo
)
project2
.
team
<<
[
user
,
role
]
project2
.
deploy_keys
<<
private_deploy_key
visit
namespace_project_settings_repository_path
(
project
.
namespace
,
project
)
find
(
'li'
,
text:
private_deploy_key
.
title
).
click_link
(
'Edit'
)
fill_in
'deploy_key_title'
,
with:
'updated_deploy_key'
check
'deploy_key_can_push'
click_button
'Save changes'
expect
(
page
).
to
have_content
(
'updated_deploy_key'
)
expect
(
page
).
to
have_content
(
'Write access allowed'
)
end
scenario
'remove an existing deploy key'
do
project
.
deploy_keys
<<
private_deploy_key
visit
namespace_project_settings_repository_path
(
project
.
namespace
,
project
)
...
...
spec/requests/api/deploy_keys_spec.rb
View file @
c7bcebd5
...
...
@@ -160,6 +160,16 @@ describe API::DeployKeys do
expect
(
json_response
[
'title'
]).
to
eq
(
'new title'
)
expect
(
json_response
[
'can_push'
]).
to
eq
(
true
)
end
it
'updates a private ssh key from projects user has access with correct attributes'
do
create
(
:deploy_keys_project
,
project:
project2
,
deploy_key:
private_deploy_key
)
put
api
(
"/projects/
#{
project
.
id
}
/deploy_keys/
#{
private_deploy_key
.
id
}
"
,
admin
),
{
title:
'new title'
,
can_push:
true
}
expect
(
json_response
[
'id'
]).
to
eq
(
private_deploy_key
.
id
)
expect
(
json_response
[
'title'
]).
to
eq
(
'new title'
)
expect
(
json_response
[
'can_push'
]).
to
eq
(
true
)
end
end
describe
'DELETE /projects/:id/deploy_keys/:key_id'
do
...
...
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