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
Boxiang Sun
gitlab-ce
Commits
6d81905f
Commit
6d81905f
authored
May 16, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce a new Keys::DestroyService service
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
c75ae237
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
2 deletions
+27
-2
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+1
-1
app/services/keys/base_service.rb
app/services/keys/base_service.rb
+1
-1
app/services/keys/destroy_service.rb
app/services/keys/destroy_service.rb
+12
-0
spec/services/keys/destroy_service_spec.rb
spec/services/keys/destroy_service_spec.rb
+13
-0
No files found.
app/controllers/profiles/keys_controller.rb
View file @
6d81905f
...
...
@@ -23,7 +23,7 @@ class Profiles::KeysController < Profiles::ApplicationController
def
destroy
@key
=
current_user
.
keys
.
find
(
params
[
:id
])
@key
.
destroy
Keys
::
DestroyService
.
new
(
current_user
).
execute
(
@key
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
profile_keys_url
,
status:
302
}
...
...
app/services/keys/base_service.rb
View file @
6d81905f
...
...
@@ -2,7 +2,7 @@ module Keys
class
BaseService
attr_accessor
:user
,
:params
def
initialize
(
user
,
params
)
def
initialize
(
user
,
params
=
{}
)
@user
,
@params
=
user
,
params
@ip_address
=
@params
.
delete
(
:ip_address
)
end
...
...
app/services/keys/destroy_service.rb
0 → 100644
View file @
6d81905f
module
Keys
class
DestroyService
<
::
Keys
::
BaseService
def
execute
(
key
)
key
.
destroy
if
destroy_possible?
(
key
)
end
# overriden in EE::Keys::DestroyService
def
destroy_possible?
(
key
)
true
end
end
end
spec/services/keys/destroy_service_spec.rb
0 → 100644
View file @
6d81905f
require
'spec_helper'
describe
Keys
::
DestroyService
do
let
(
:user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
user
)
}
it
'destroys a key'
do
key
=
create
(
:key
)
expect
{
subject
.
execute
(
key
)
}.
to
change
(
Key
,
: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