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
df313634
Commit
df313634
authored
Feb 03, 2016
by
Grzegorz Bizon
Committed by
Grzegorz Bizon
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not allow to modify build if it has been erased
parent
21152d7d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+3
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+35
-21
No files found.
lib/ci/api/builds.rb
View file @
df313634
...
...
@@ -38,6 +38,8 @@ module Ci
authenticate_runner!
update_runner_last_contact
build
=
Ci
::
Build
.
where
(
runner_id:
current_runner
.
id
).
running
.
find
(
params
[
:id
])
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
build
.
update_attributes
(
trace:
params
[
:trace
])
if
params
[
:trace
]
case
params
[
:state
].
to_s
...
...
@@ -99,6 +101,7 @@ module Ci
not_found!
unless
build
authenticate_build_token!
(
build
)
forbidden!
(
'Build is not running!'
)
unless
build
.
running?
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts
=
uploaded_file
(
:file
,
artifacts_upload_path
)
...
...
spec/requests/ci/api/builds_spec.rb
View file @
df313634
...
...
@@ -131,39 +131,41 @@ describe Ci::API::API do
end
describe
"PUT /builds/:id"
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)}
let
(
:build
)
{
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
runner_id:
runner
.
id
)
}
let
(
:commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:build
)
{
create
(
:ci_build_with_trace
,
commit:
commit
,
runner_id:
runner
.
id
)
}
it
"should update a running build"
do
before
do
build
.
run!
put
ci_api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
end
it
"should update a running build"
do
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'Should not override trace information when no trace is given'
do
build
.
run!
build
.
update!
(
trace:
'hello_world'
)
put
ci_api
(
"/builds/
#{
build
.
id
}
"
),
token:
runner
.
token
expect
(
build
.
reload
.
trace
).
to
eq
'hello_world'
it
'should not override trace information when no trace is given'
do
expect
(
build
.
reload
.
trace
).
to
eq
'BUILD TRACE'
end
context
'build has been erased'
do
let
(
:build
)
{
create
(
:ci_build
,
runner_id:
runner
.
id
,
erased_at:
Time
.
now
)
}
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
403
end
end
end
describe
'DELETE /builds/:id/content'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
)
}
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
it
'should
erase build content
'
do
expect
(
response
.
status
).
to
eq
200
end
it
'should remove build artifacts'
do
expect
(
build
.
trace
).
to
be_empty
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
...
...
@@ -209,9 +211,10 @@ describe Ci::API::API do
end
end
context
'token is invalid'
do
it
'should respond with forbidden'
do
post
authorize_url
,
{
token:
'invalid'
,
filesize:
100
}
context
'authorization token is invalid'
do
before
{
post
authorize_url
,
{
token:
'invalid'
,
filesize:
100
}
}
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
(
403
)
end
end
...
...
@@ -224,6 +227,15 @@ describe Ci::API::API do
allow
(
ArtifactUploader
).
to
receive
(
:artifacts_upload_path
).
and_return
(
'/'
)
end
context
'build has been erased'
do
let
(
:build
)
{
create
(
:ci_build
,
erased_at:
Time
.
now
)
}
before
{
upload_artifacts
(
file_upload
,
headers_with_token
)
}
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
403
end
end
context
"should post artifact to running build"
do
it
"uses regual file post"
do
upload_artifacts
(
file_upload
,
headers_with_token
,
false
)
...
...
@@ -252,7 +264,9 @@ describe Ci::API::API do
let
(
:stored_artifacts_file
)
{
build
.
reload
.
artifacts_file
.
file
}
let
(
:stored_metadata_file
)
{
build
.
reload
.
artifacts_metadata
.
file
}
before
{
post
(
post_url
,
post_data
,
headers_with_token
)
}
before
do
post
(
post_url
,
post_data
,
headers_with_token
)
end
context
'post data accelerated by workhorse is correct'
do
let
(
:post_data
)
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