BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a17bf380
Commit
a17bf380
authored
Dec 30, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cancel/retry features to builds API
parent
593d87ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletion
+65
-1
builds.rb
spec/factories/ci/builds.rb
+4
-0
builds_spec.rb
spec/requests/api/builds_spec.rb
+61
-1
No files found.
spec/factories/ci/builds.rb
View file @
a17bf380
...
@@ -60,5 +60,9 @@ FactoryGirl.define do
...
@@ -60,5 +60,9 @@ FactoryGirl.define do
id
999
id
999
trace
'BUILD TRACE'
trace
'BUILD TRACE'
end
end
factory
:ci_build_canceled
do
status
'canceled'
end
end
end
end
end
spec/requests/api/builds_spec.rb
View file @
a17bf380
...
@@ -7,10 +7,11 @@ describe API::API, api: true do
...
@@ -7,10 +7,11 @@ describe API::API, api: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:project_member
,
user:
user
,
project:
project
,
access_level:
ProjectMember
::
MASTER
)
}
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!
(
:
reporter
)
{
create
(
:project_member
,
user:
user2
,
project:
project
,
access_level:
ProjectMember
::
REPORTER
)
}
let
(
:commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:build
)
{
create
(
:ci_build
,
commit:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
commit:
commit
)
}
let
(
:build_with_trace
)
{
create
(
:ci_build_with_trace
,
commit:
commit
)
}
let
(
:build_with_trace
)
{
create
(
:ci_build_with_trace
,
commit:
commit
)
}
let
(
:build_canceled
)
{
create
(
:ci_build_canceled
,
commit:
commit
)
}
describe
'GET /projects/:id/builds '
do
describe
'GET /projects/:id/builds '
do
context
'authorized user'
do
context
'authorized user'
do
...
@@ -85,4 +86,63 @@ describe API::API, api: true do
...
@@ -85,4 +86,63 @@ describe API::API, api: true do
end
end
end
end
end
end
describe
'GET /projects/:id/builds/:build_id/cancel'
do
context
'authorized user'
do
context
'user with :manage_builds persmission'
do
it
'should cancel running or pending build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/cancel"
,
user
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
project
.
builds
.
first
.
status
).
to
eq
(
'canceled'
)
end
end
context
'user without :manage_builds permission'
do
it
'should not cancel build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/cancel"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
context
'unauthorized user'
do
it
'should not cancel build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/cancel"
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'GET /projects/:id/builds/:build_id/retry'
do
context
'authorized user'
do
context
'user with :manage_builds persmission'
do
it
'should retry non-running build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build_canceled
.
id
}
/retry"
,
user
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
project
.
builds
.
first
.
status
).
to
eq
(
'canceled'
)
expect
(
json_response
[
'status'
]).
to
eq
(
'pending'
)
end
end
context
'user without :manage_builds permission'
do
it
'should not retry build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build_canceled
.
id
}
/retry"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
end
context
'unauthorized user'
do
it
'should not retry build'
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build_canceled
.
id
}
/retry"
)
expect
(
response
.
status
).
to
eq
(
401
)
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