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
b13c89b1
Commit
b13c89b1
authored
Jun 19, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DestroyService for GPG keys and use for deleting gpg keys via API
parent
1119b3d6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
app/services/gpg_keys/destroy_service.rb
app/services/gpg_keys/destroy_service.rb
+9
-0
lib/api/users.rb
lib/api/users.rb
+4
-3
spec/services/gpg_keys/destroy_service_spec.rb
spec/services/gpg_keys/destroy_service_spec.rb
+15
-0
No files found.
app/services/gpg_keys/destroy_service.rb
0 → 100644
View file @
b13c89b1
# frozen_string_literal: true
module
GpgKeys
class
DestroyService
<
Keys
::
BaseService
def
execute
(
key
)
key
.
destroy
end
end
end
lib/api/users.rb
View file @
b13c89b1
...
...
@@ -374,9 +374,10 @@ module API
key
=
user
.
gpg_keys
.
find_by
(
id:
params
[
:key_id
])
not_found!
(
'GPG Key'
)
unless
key
key
.
destroy
no_content!
destroy_conditionally!
(
key
)
do
|
key
|
destroy_service
=
::
GpgKeys
::
DestroyService
.
new
(
current_user
)
destroy_service
.
execute
(
key
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/services/gpg_keys/destroy_service_spec.rb
0 → 100644
View file @
b13c89b1
# frozen_string_literal: true
require
'spec_helper'
describe
GpgKeys
::
DestroyService
do
let
(
:user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
user
)
}
it
'destroys the GPG key'
do
gpg_key
=
create
(
:gpg_key
)
expect
{
subject
.
execute
(
gpg_key
)
}.
to
change
(
GpgKey
,
:count
).
by
(
-
1
)
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