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
02fc1846
Commit
02fc1846
authored
May 02, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve specs for jobs API regarding manual actions
parent
e5df86f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
17 deletions
+50
-17
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+50
-17
No files found.
spec/requests/api/jobs_spec.rb
View file @
02fc1846
require
'spec_helper'
require
'spec_helper'
describe
API
::
Jobs
,
api:
true
do
describe
API
::
Jobs
,
:api
do
include
ApiHelpers
let!
(
:project
)
do
create
(
:project
,
:repository
,
public_builds:
false
)
end
let!
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
)
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:api_user
)
{
user
}
let
(
:api_user
)
{
user
}
let
!
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
public_builds:
false
)
}
let
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
project:
project
).
user
}
let
!
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
let
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
).
user
}
let
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
project:
project
)
}
let
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
)
}
before
do
let!
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
)
}
project
.
add_developer
(
user
)
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
end
describe
'GET /projects/:id/jobs'
do
describe
'GET /projects/:id/jobs'
do
let
(
:query
)
{
Hash
.
new
}
let
(
:query
)
{
Hash
.
new
}
...
@@ -213,7 +223,7 @@ describe API::Jobs, api: true do
...
@@ -213,7 +223,7 @@ describe API::Jobs, api: true do
end
end
describe
'GET /projects/:id/artifacts/:ref_name/download?job=name'
do
describe
'GET /projects/:id/artifacts/:ref_name/download?job=name'
do
let
(
:api_user
)
{
reporter
.
user
}
let
(
:api_user
)
{
reporter
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
before
do
...
@@ -237,7 +247,7 @@ describe API::Jobs, api: true do
...
@@ -237,7 +247,7 @@ describe API::Jobs, api: true do
end
end
context
'when logging as guest'
do
context
'when logging as guest'
do
let
(
:api_user
)
{
guest
.
user
}
let
(
:api_user
)
{
guest
}
before
do
before
do
get_for_ref
get_for_ref
...
@@ -347,7 +357,7 @@ describe API::Jobs, api: true do
...
@@ -347,7 +357,7 @@ describe API::Jobs, api: true do
end
end
context
'user without :update_build permission'
do
context
'user without :update_build permission'
do
let
(
:api_user
)
{
reporter
.
user
}
let
(
:api_user
)
{
reporter
}
it
'does not cancel job'
do
it
'does not cancel job'
do
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
...
@@ -381,7 +391,7 @@ describe API::Jobs, api: true do
...
@@ -381,7 +391,7 @@ describe API::Jobs, api: true do
end
end
context
'user without :update_build permission'
do
context
'user without :update_build permission'
do
let
(
:api_user
)
{
reporter
.
user
}
let
(
:api_user
)
{
reporter
}
it
'does not retry job'
do
it
'does not retry job'
do
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
...
@@ -457,16 +467,39 @@ describe API::Jobs, api: true do
...
@@ -457,16 +467,39 @@ describe API::Jobs, api: true do
describe
'POST /projects/:id/jobs/:job_id/play'
do
describe
'POST /projects/:id/jobs/:job_id/play'
do
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/play"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/play"
,
api_
user
)
end
end
context
'on an playable job'
do
context
'on an playable job'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
pipeline
)
}
context
'when user is authorized to trigger a manual action'
do
it
'plays the job'
do
it
'plays the job'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'user'
][
'id'
]).
to
eq
(
user
.
id
)
expect
(
json_response
[
'user'
][
'id'
]).
to
eq
(
user
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
build
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
build
.
id
)
expect
(
build
.
reload
).
to
be_pending
end
end
context
'when user is not authorized to trigger a manual action'
do
context
'when user does not have access to the project'
do
let
(
:api_user
)
{
create
(
:user
)
}
it
'does not trigger a manual action'
do
expect
(
build
.
reload
).
to
be_manual
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when user is not allowed to trigger the manual action'
do
let
(
:api_user
)
{
reporter
}
it
'does not trigger a manual action'
do
expect
(
build
.
reload
).
to
be_manual
expect
(
response
).
to
have_http_status
(
403
)
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