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
9c7fffb6
Commit
9c7fffb6
authored
Mar 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete deploy key when last connection to a project is destroyed.
parent
409097bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
2 deletions
+45
-2
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+3
-2
app/models/deploy_keys_project.rb
app/models/deploy_keys_project.rb
+8
-0
spec/models/deploy_keys_project_spec.rb
spec/models/deploy_keys_project_spec.rb
+33
-0
No files found.
CHANGELOG
View file @
9c7fffb6
...
@@ -74,6 +74,7 @@ v 7.9.0 (unreleased)
...
@@ -74,6 +74,7 @@ v 7.9.0 (unreleased)
- Raise recommended number of unicorn workers from 2 to 3
- Raise recommended number of unicorn workers from 2 to 3
- Use same layout and interactivity for project members as group members.
- Use same layout and interactivity for project members as group members.
- Prevent gitlab-shell character encoding issues by receiving its changes as raw data.
- Prevent gitlab-shell character encoding issues by receiving its changes as raw data.
- Delete deploy key when last connection to a project is destroyed.
v 7.8.4
v 7.8.4
- Fix issue_tracker_id substitution in custom issue trackers
- Fix issue_tracker_id substitution in custom issue trackers
...
...
app/controllers/projects/deploy_keys_controller.rb
View file @
9c7fffb6
...
@@ -37,7 +37,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
...
@@ -37,7 +37,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
@key
.
destroy
@key
.
destroy
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
project_deploy_keys_url
}
format
.
html
{
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
@project
)
}
format
.
js
{
render
nothing:
true
}
format
.
js
{
render
nothing:
true
}
end
end
end
end
...
@@ -50,7 +51,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
...
@@ -50,7 +51,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
end
def
disable
def
disable
@project
.
deploy_keys_projects
.
where
(
deploy_key_id:
params
[
:id
]).
last
.
destroy
@project
.
deploy_keys_projects
.
find_by
(
deploy_key_id:
params
[
:id
])
.
destroy
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
@project
)
@project
)
...
...
app/models/deploy_keys_project.rb
View file @
9c7fffb6
...
@@ -16,4 +16,12 @@ class DeployKeysProject < ActiveRecord::Base
...
@@ -16,4 +16,12 @@ class DeployKeysProject < ActiveRecord::Base
validates
:deploy_key_id
,
presence:
true
validates
:deploy_key_id
,
presence:
true
validates
:deploy_key_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:deploy_key_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:project_id
,
presence:
true
validates
:project_id
,
presence:
true
after_destroy
:destroy_orphaned_deploy_key
private
def
destroy_orphaned_deploy_key
self
.
deploy_key
.
destroy
if
self
.
deploy_key
.
deploy_keys_projects
.
length
==
0
end
end
end
spec/models/deploy_keys_project_spec.rb
View file @
9c7fffb6
...
@@ -21,4 +21,37 @@ describe DeployKeysProject do
...
@@ -21,4 +21,37 @@ describe DeployKeysProject do
it
{
is_expected
.
to
validate_presence_of
(
:project_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:deploy_key_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:deploy_key_id
)
}
end
end
describe
"Destroying"
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
create
(
:deploy_keys_project
,
project:
project
)
}
let
(
:deploy_key
)
{
subject
.
deploy_key
}
context
"when the deploy key is only used by this project"
do
it
"destroys the deploy key"
do
subject
.
destroy
expect
{
deploy_key
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
context
"when the deploy key is used by more than one project"
do
let!
(
:other_project
)
{
create
(
:project
)
}
before
do
other_project
.
deploy_keys
<<
deploy_key
end
it
"doesn't destroy the deploy key"
do
subject
.
destroy
expect
{
deploy_key
.
reload
}.
not_to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
end
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