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
593d87ea
Commit
593d87ea
authored
Dec 30, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for build details/traces features in builds API
parent
d2601211
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
2 deletions
+44
-2
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+6
-0
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+38
-2
No files found.
spec/factories/ci/builds.rb
View file @
593d87ea
...
...
@@ -30,6 +30,7 @@ FactoryGirl.define do
name
'test'
ref
'master'
tag
false
created_at
'Di 29. Okt 09:50:00 CET 2013'
started_at
'Di 29. Okt 09:51:28 CET 2013'
finished_at
'Di 29. Okt 09:53:28 CET 2013'
commands
'ls -a'
...
...
@@ -54,5 +55,10 @@ FactoryGirl.define do
factory
:ci_build_tag
do
tag
true
end
factory
:ci_build_with_trace
do
id
999
trace
'BUILD TRACE'
end
end
end
spec/requests/api/builds_spec.rb
View file @
593d87ea
...
...
@@ -8,6 +8,9 @@ describe API::API, api: true do
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:project_member
,
user:
user
,
project:
project
,
access_level:
ProjectMember
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:project_member
,
user:
user2
,
project:
project
,
access_level:
ProjectMember
::
GUEST
)
}
let
(
:commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:build
)
{
create
(
:ci_build
,
commit:
commit
)
}
let
(
:build_with_trace
)
{
create
(
:ci_build_with_trace
,
commit:
commit
)
}
describe
'GET /projects/:id/builds '
do
context
'authorized user'
do
...
...
@@ -32,7 +35,7 @@ describe API::API, api: true do
describe
'GET /projects/:id/builds/commit/:sha'
do
context
'authorized user'
do
it
'should return project builds for specific commit'
do
project
.
ensure_ci_commit
(
project
.
repository
.
commit
.
sha
)
project
.
ensure_ci_commit
(
commit
.
sha
)
get
api
(
"/projects/
#{
project
.
id
}
/builds/commit/
#{
project
.
ci_commits
.
first
.
sha
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
...
...
@@ -42,11 +45,44 @@ describe API::API, api: true do
context
'unauthorized user'
do
it
'should not return project builds'
do
project
.
ensure_ci_commit
(
project
.
repository
.
commit
.
sha
)
project
.
ensure_ci_commit
(
commit
.
sha
)
get
api
(
"/projects/
#{
project
.
id
}
/builds/commit/
#{
project
.
ci_commits
.
first
.
sha
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'GET /projects/:id/builds/:build_id(/trace)?'
do
context
'authorized user'
do
it
'should return specific build data'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'commit'
][
'sha'
]).
to
eq
(
commit
.
sha
)
end
it
'should return specific build trace'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build_with_trace
.
id
}
/trace"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
body
).
to
eq
(
build_with_trace
.
trace
)
end
end
context
'unauthorized user'
do
it
'should not return specific build data'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
end
it
'should not return specific build trace'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build_with_trace
.
id
}
/trace"
)
expect
(
response
.
status
).
to
eq
(
401
)
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