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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
21152d7d
Commit
21152d7d
authored
Feb 03, 2016
by
Grzegorz Bizon
Committed by
Grzegorz Bizon
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use DELETE verb for erasing a build content
Also added API specs for that
parent
6ca99bd8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
11 deletions
+29
-11
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+1
-1
config/routes.rb
config/routes.rb
+1
-1
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+4
-2
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+5
-6
spec/models/build_spec.rb
spec/models/build_spec.rb
+0
-1
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+18
-0
No files found.
app/views/projects/builds/show.html.haml
View file @
21152d7d
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
-
if
@build
.
eraseable?
-
if
@build
.
eraseable?
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :
put
,
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :
delete
,
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
=
icon
(
'eraser'
)
=
icon
(
'eraser'
)
Erase
Erase
...
...
config/routes.rb
View file @
21152d7d
...
@@ -617,7 +617,7 @@ Rails.application.routes.draw do
...
@@ -617,7 +617,7 @@ Rails.application.routes.draw do
get
:status
get
:status
post
:cancel
post
:cancel
post
:retry
post
:retry
put
:erase
delete
:erase
end
end
resource
:artifacts
,
only:
[]
do
resource
:artifacts
,
only:
[]
do
...
...
lib/ci/api/builds.rb
View file @
21152d7d
...
@@ -156,6 +156,7 @@ module Ci
...
@@ -156,6 +156,7 @@ module Ci
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build_token!
(
build
)
build
.
remove_artifacts_file!
build
.
remove_artifacts_file!
build
.
remove_artifacts_metadata!
build
.
remove_artifacts_metadata!
end
end
...
@@ -168,11 +169,12 @@ module Ci
...
@@ -168,11 +169,12 @@ module Ci
# Headers:
# Headers:
# BUILD-TOKEN (required) - The build authorization token, the same as token
# BUILD-TOKEN (required) - The build authorization token, the same as token
# Example Request:
# Example Request:
#
PUT /builds/:id/erase
#
DELETE /builds/:id/content
put
':id/erase
'
do
delete
':id/content
'
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build_token!
(
build
)
build
.
erase!
build
.
erase!
end
end
end
end
...
...
spec/factories/ci/builds.rb
View file @
21152d7d
...
@@ -62,14 +62,13 @@ FactoryGirl.define do
...
@@ -62,14 +62,13 @@ FactoryGirl.define do
trait
:artifacts
do
trait
:artifacts
do
after
(
:create
)
do
|
build
,
_
|
after
(
:create
)
do
|
build
,
_
|
build
.
artifacts_file
=
build
.
artifacts_file
=
fixture_file_upload
(
Rails
.
root
+
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts.zip'
),
'spec/fixtures/ci_build_artifacts.zip'
,
'application/zip'
)
'application/zip'
)
build
.
artifacts_metadata
=
build
.
artifacts_metadata
=
fixture_file_upload
(
Rails
.
root
+
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts_metadata.gz'
),
'spec/fixtures/ci_build_artifacts_metadata.gz'
,
' application/x-gzip'
)
'application/x-gzip'
)
build
.
save!
build
.
save!
end
end
end
end
...
...
spec/models/build_spec.rb
View file @
21152d7d
...
@@ -497,6 +497,5 @@ describe Ci::Build, models: true do
...
@@ -497,6 +497,5 @@ describe Ci::Build, models: true do
expect
(
@build2
.
merge_request
.
id
).
to
eq
(
@merge_request
.
id
)
expect
(
@build2
.
merge_request
.
id
).
to
eq
(
@merge_request
.
id
)
end
end
end
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
21152d7d
...
@@ -148,6 +148,24 @@ describe Ci::API::API do
...
@@ -148,6 +148,24 @@ describe Ci::API::API do
end
end
end
end
describe
'DELETE /builds/:id/content'
do
before
{
delete
ci_api
(
"/builds/
#{
build
.
id
}
/content"
),
token:
build
.
token
}
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
)
}
it
'should respond with valid status'
do
expect
(
response
.
status
).
to
eq
200
end
it
'should remove build artifacts'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
it
'should remove build trace'
do
expect
(
build
.
trace
).
to
be_empty
end
end
context
"Artifacts"
do
context
"Artifacts"
do
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
...
...
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