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
b7e5f73c
Commit
b7e5f73c
authored
Nov 13, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise exception when user is not authorized
parent
0bc14b45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
+3
-9
app/services/ci/destroy_pipeline_service.rb
app/services/ci/destroy_pipeline_service.rb
+1
-1
spec/services/ci/destroy_pipeline_service_spec.rb
spec/services/ci/destroy_pipeline_service_spec.rb
+2
-8
No files found.
app/services/ci/destroy_pipeline_service.rb
View file @
b7e5f73c
...
...
@@ -3,7 +3,7 @@
module
Ci
class
DestroyPipelineService
<
BaseService
def
execute
(
pipeline
)
r
eturn
false
unless
can?
(
current_user
,
:destroy_pipeline
,
pipeline
)
r
aise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:destroy_pipeline
,
pipeline
)
AuditEventService
.
new
(
current_user
,
pipeline
).
security_event
...
...
spec/services/ci/destroy_pipeline_service_spec.rb
View file @
b7e5f73c
...
...
@@ -53,14 +53,8 @@ describe ::Ci::DestroyPipelineService do
context
'user is not owner'
do
let
(
:user
)
{
create
(
:user
)
}
it
'returns false'
do
is_expected
.
to
eq
(
false
)
end
it
'does not destroy the pipeline'
do
subject
expect
{
pipeline
.
reload
}.
not_to
raise_error
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Access
::
AccessDeniedError
)
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