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
020623f3
Commit
020623f3
authored
Feb 02, 2016
by
Grzegorz Bizon
Committed by
Grzegorz Bizon
Feb 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve CI API specs related to operations on build
Conflicts: spec/factories/ci/builds.rb
parent
3b080be3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
21 deletions
+49
-21
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+15
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+34
-21
No files found.
spec/factories/ci/builds.rb
View file @
020623f3
...
@@ -65,5 +65,20 @@ FactoryGirl.define do
...
@@ -65,5 +65,20 @@ FactoryGirl.define do
build
.
trace
=
'BUILD TRACE'
build
.
trace
=
'BUILD TRACE'
end
end
end
end
trait
:artifacts
do
after
(
:create
)
do
|
build
,
_
|
build
.
artifacts_file
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/ci_build_artifacts.zip'
,
'application/zip'
)
build
.
artifacts_metadata
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/ci_build_artifacts_metadata.gz'
,
'application/x-gzip'
)
build
.
save!
end
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
020623f3
...
@@ -151,8 +151,8 @@ describe Ci::API::API do
...
@@ -151,8 +151,8 @@ describe Ci::API::API do
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'
)
}
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
}
let
(
:commit
)
{
create
(
:ci_commit
,
project:
project
)
}
let
(
:build
)
{
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
,
runner_id:
runner
.
id
)
}
let
(
:build
)
{
create
(
:ci_build
,
commit:
commit
,
runner_id:
runner
.
id
)
}
let
(
:authorize_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts/authorize"
)
}
let
(
:authorize_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts/authorize"
)
}
let
(
:post_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:post_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:delete_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:delete_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
...
@@ -349,33 +349,46 @@ describe Ci::API::API do
...
@@ -349,33 +349,46 @@ describe Ci::API::API do
end
end
end
end
describe
"DELETE /builds/:id/artifacts"
do
describe
'DELETE /builds/:id/artifacts'
do
before
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
build
.
run!
before
{
delete
delete_url
,
token:
build
.
token
}
post
delete_url
,
token:
build
.
token
,
file:
file_upload
end
it
"should delete artifact build"
do
it
'should respond valid status'
do
build
.
success
delete
delete_url
,
token:
build
.
token
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
describe
"GET /builds/:id/artifacts"
do
it
'should remove artifacts file'
do
before
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
build
.
run!
end
end
it
"should download artifact"
do
it
'should remove artifacts metadata'
do
build
.
update_attributes
(
artifacts_file:
file_upload
)
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
get
get_url
,
token:
build
.
token
end
expect
(
response
.
status
).
to
eq
(
200
)
end
describe
'GET /builds/:id/artifacts'
do
before
{
get
get_url
,
token:
build
.
token
}
context
'build has artifacts'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'attachment; filename=ci_build_artifacts.zip'
}
end
it
'should respond with valid status'
do
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should download artifact'
do
expect
(
response
.
headers
).
to
include
download_headers
end
end
end
it
"should fail to download if no artifact uploaded"
do
context
'build does not has artifacts'
do
get
get_url
,
token:
build
.
token
it
'should respond with not found'
do
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
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