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
Jérome Perrin
gitlab-ce
Commits
d2601211
Commit
d2601211
authored
Dec 29, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for build listings in API
parent
b2fbeb37
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
3 deletions
+58
-3
lib/api/builds.rb
lib/api/builds.rb
+6
-3
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+52
-0
No files found.
lib/api/builds.rb
View file @
d2601211
...
@@ -27,7 +27,10 @@ module API
...
@@ -27,7 +27,10 @@ module API
# Example Request:
# Example Request:
# GET /projects/:id/builds/commit/:sha
# GET /projects/:id/builds/commit/:sha
get
':id/builds/commit/:sha'
do
get
':id/builds/commit/:sha'
do
builds
=
user_project
.
ci_commits
.
find_by_sha
(
params
[
:sha
]).
builds
.
order
(
'id DESC'
)
commit
=
user_project
.
ci_commits
.
find_by_sha
(
params
[
:sha
])
return
not_found!
unless
commit
builds
=
commit
.
builds
.
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
filter_builds
(
builds
,
params
[
:scope
])
present
paginate
(
builds
),
with:
Entities
::
Build
present
paginate
(
builds
),
with:
Entities
::
Build
end
end
...
@@ -65,7 +68,7 @@ module API
...
@@ -65,7 +68,7 @@ module API
body
trace
body
trace
end
end
#
c
ancel a specific build of a project
#
C
ancel a specific build of a project
#
#
# parameters:
# parameters:
# id (required) - the id of a project
# id (required) - the id of a project
...
@@ -83,7 +86,7 @@ module API
...
@@ -83,7 +86,7 @@ module API
present
build
,
with:
Entities
::
Build
present
build
,
with:
Entities
::
Build
end
end
#
cancel
a specific build of a project
#
Retry
a specific build of a project
#
#
# parameters:
# parameters:
# id (required) - the id of a project
# id (required) - the id of a project
...
...
spec/requests/api/builds_spec.rb
0 → 100644
View file @
d2601211
require
'spec_helper'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
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
)
}
describe
'GET /projects/:id/builds '
do
context
'authorized user'
do
it
'should return project builds'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds"
,
user
)
puts
json_response
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
end
end
context
'unauthorized user'
do
it
'should not return project builds'
do
get
api
(
"/projects/
#{
project
.
id
}
/builds"
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
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
)
get
api
(
"/projects/
#{
project
.
id
}
/builds/commit/
#{
project
.
ci_commits
.
first
.
sha
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
end
end
context
'unauthorized user'
do
it
'should not return project builds'
do
project
.
ensure_ci_commit
(
project
.
repository
.
commit
.
sha
)
get
api
(
"/projects/
#{
project
.
id
}
/builds/commit/
#{
project
.
ci_commits
.
first
.
sha
}
"
)
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