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
5b45cd24
Commit
5b45cd24
authored
Nov 12, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement MVC for Pipeline deletion API
parent
d15c9ae3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
lib/api/pipelines.rb
lib/api/pipelines.rb
+15
-0
spec/requests/api/pipelines_spec.rb
spec/requests/api/pipelines_spec.rb
+47
-0
No files found.
lib/api/pipelines.rb
View file @
5b45cd24
...
@@ -81,6 +81,21 @@ module API
...
@@ -81,6 +81,21 @@ module API
present
pipeline
,
with:
Entities
::
Pipeline
present
pipeline
,
with:
Entities
::
Pipeline
end
end
desc
'Deletes a pipeline'
do
detail
'This feature was introduced in GitLab 11.6'
http_codes
[[
204
,
'Pipeline was deleted'
],
[
403
,
'Forbidden'
]]
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
end
delete
':id/pipelines/:pipeline_id'
do
authorize!
:admin_pipeline
,
user_project
AuditEventService
.
new
(
current_user
,
user_project
).
security_event
destroy_conditionally!
(
pipeline
)
end
desc
'Retry builds in the pipeline'
do
desc
'Retry builds in the pipeline'
do
detail
'This feature was introduced in GitLab 8.11.'
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Pipeline
success
Entities
::
Pipeline
...
...
spec/requests/api/pipelines_spec.rb
View file @
5b45cd24
...
@@ -438,6 +438,53 @@ describe API::Pipelines do
...
@@ -438,6 +438,53 @@ describe API::Pipelines do
end
end
end
end
describe
'DELETE /projects/:id/pipelines/:pipeline_id'
do
context
'authorized user'
do
it
'deletes the pipeline'
do
delete
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
{
pipeline
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'returns 404 when it does not exist'
do
delete
api
(
"/projects/
#{
project
.
id
}
/pipelines/123456"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Not found'
end
it
'logs an audit event'
do
expect
{
delete
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
user
)
}.
to
change
{
SecurityEvent
.
count
}.
by
(
1
)
end
context
'when the pipeline has jobs'
do
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
,
user:
user
)
end
let!
(
:build
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
it
'deletes associated jobs'
do
delete
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
{
build
.
reload
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
end
context
'unauthorized user'
do
it
'should not return a project pipeline'
do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Project Not Found'
end
end
end
describe
'POST /projects/:id/pipelines/:pipeline_id/retry'
do
describe
'POST /projects/:id/pipelines/:pipeline_id/retry'
do
context
'authorized user'
do
context
'authorized user'
do
let!
(
:pipeline
)
do
let!
(
:pipeline
)
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