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
c81db244
Commit
c81db244
authored
Jun 06, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix raw_path with the new job path, rename to job
in the tests
parent
35083dc9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
197 additions
and
195 deletions
+197
-195
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-1
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+68
-68
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+70
-70
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+58
-56
No files found.
app/serializers/build_details_entity.rb
View file @
c81db244
...
@@ -28,7 +28,7 @@ class BuildDetailsEntity < BuildEntity
...
@@ -28,7 +28,7 @@ class BuildDetailsEntity < BuildEntity
end
end
expose
:raw_path
do
|
build
|
expose
:raw_path
do
|
build
|
raw_namespace_project_
build
_path
(
project
.
namespace
,
project
,
build
)
raw_namespace_project_
job
_path
(
project
.
namespace
,
project
,
build
)
end
end
private
private
...
...
spec/controllers/projects/jobs_controller_spec.rb
View file @
c81db244
...
@@ -28,7 +28,7 @@ describe Projects::JobsController do
...
@@ -28,7 +28,7 @@ describe Projects::JobsController do
get_index
(
scope:
'running'
)
get_index
(
scope:
'running'
)
end
end
it
'has only running
build
s'
do
it
'has only running
job
s'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
assigns
(
:builds
).
first
.
status
).
to
eq
(
'running'
)
expect
(
assigns
(
:builds
).
first
.
status
).
to
eq
(
'running'
)
end
end
...
@@ -41,7 +41,7 @@ describe Projects::JobsController do
...
@@ -41,7 +41,7 @@ describe Projects::JobsController do
get_index
(
scope:
'finished'
)
get_index
(
scope:
'finished'
)
end
end
it
'has only finished
build
s'
do
it
'has only finished
job
s'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
assigns
(
:builds
).
first
.
status
).
to
eq
(
'success'
)
expect
(
assigns
(
:builds
).
first
.
status
).
to
eq
(
'success'
)
end
end
...
@@ -67,7 +67,7 @@ describe Projects::JobsController do
...
@@ -67,7 +67,7 @@ describe Projects::JobsController do
context
'number of queries'
do
context
'number of queries'
do
before
do
before
do
Ci
::
Build
::
AVAILABLE_STATUSES
.
each
do
|
status
|
Ci
::
Build
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_
build
(
status
,
status
)
create_
job
(
status
,
status
)
end
end
RequestStore
.
begin!
RequestStore
.
begin!
...
@@ -83,7 +83,7 @@ describe Projects::JobsController do
...
@@ -83,7 +83,7 @@ describe Projects::JobsController do
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
8
)
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
8
)
end
end
def
create_
build
(
name
,
status
)
def
create_
job
(
name
,
status
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
)
create
(
:ci_build
,
:tags
,
:triggered
,
:artifacts
,
create
(
:ci_build
,
:tags
,
:triggered
,
:artifacts
,
pipeline:
pipeline
,
name:
name
,
status:
status
)
pipeline:
pipeline
,
name:
name
,
status:
status
)
...
@@ -101,21 +101,21 @@ describe Projects::JobsController do
...
@@ -101,21 +101,21 @@ describe Projects::JobsController do
end
end
describe
'GET show'
do
describe
'GET show'
do
let!
(
:
build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:
job
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
context
'when requesting HTML'
do
context
'when requesting HTML'
do
context
'when
build
exists'
do
context
'when
job
exists'
do
before
do
before
do
get_show
(
id:
build
.
id
)
get_show
(
id:
job
.
id
)
end
end
it
'has a
build
'
do
it
'has a
job
'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
assigns
(
:build
).
id
).
to
eq
(
build
.
id
)
expect
(
assigns
(
:build
).
id
).
to
eq
(
job
.
id
)
end
end
end
end
context
'when
build
does not exist'
do
context
'when
job
does not exist'
do
before
do
before
do
get_show
(
id:
1234
)
get_show
(
id:
1234
)
end
end
...
@@ -135,12 +135,12 @@ describe Projects::JobsController do
...
@@ -135,12 +135,12 @@ describe Projects::JobsController do
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
get_show
(
id:
build
.
id
,
format: :json
)
get_show
(
id:
job
.
id
,
format: :json
)
end
end
it
'exposes needed information'
do
it
'exposes needed information'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
json_response
[
'raw_path'
]).
to
match
(
/
build
s\/\d+\/raw\z/
)
expect
(
json_response
[
'raw_path'
]).
to
match
(
/
job
s\/\d+\/raw\z/
)
expect
(
json_response
.
dig
(
'merge_request'
,
'path'
)).
to
match
(
/merge_requests\/\d+\z/
)
expect
(
json_response
.
dig
(
'merge_request'
,
'path'
)).
to
match
(
/merge_requests\/\d+\z/
)
expect
(
json_response
[
'new_issue_path'
])
expect
(
json_response
[
'new_issue_path'
])
.
to
include
(
'/issues/new'
)
.
to
include
(
'/issues/new'
)
...
@@ -162,35 +162,35 @@ describe Projects::JobsController do
...
@@ -162,35 +162,35 @@ describe Projects::JobsController do
get_trace
get_trace
end
end
context
'when
build
has a trace'
do
context
'when
job
has a trace'
do
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
it
'returns a trace'
do
it
'returns a trace'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
build
.
id
expect
(
json_response
[
'id'
]).
to
eq
job
.
id
expect
(
json_response
[
'status'
]).
to
eq
build
.
status
expect
(
json_response
[
'status'
]).
to
eq
job
.
status
expect
(
json_response
[
'html'
]).
to
eq
(
'BUILD TRACE'
)
expect
(
json_response
[
'html'
]).
to
eq
(
'BUILD TRACE'
)
end
end
end
end
context
'when
build
has no traces'
do
context
'when
job
has no traces'
do
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'returns no traces'
do
it
'returns no traces'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
build
.
id
expect
(
json_response
[
'id'
]).
to
eq
job
.
id
expect
(
json_response
[
'status'
]).
to
eq
build
.
status
expect
(
json_response
[
'status'
]).
to
eq
job
.
status
expect
(
json_response
[
'html'
]).
to
be_nil
expect
(
json_response
[
'html'
]).
to
be_nil
end
end
end
end
context
'when
build
has a trace with ANSI sequence and Unicode'
do
context
'when
job
has a trace with ANSI sequence and Unicode'
do
let
(
:
build
)
{
create
(
:ci_build
,
:unicode_trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:unicode_trace
,
pipeline:
pipeline
)
}
it
'returns a trace with Unicode'
do
it
'returns a trace with Unicode'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
build
.
id
expect
(
json_response
[
'id'
]).
to
eq
job
.
id
expect
(
json_response
[
'status'
]).
to
eq
build
.
status
expect
(
json_response
[
'status'
]).
to
eq
job
.
status
expect
(
json_response
[
'html'
]).
to
include
(
"ヾ(´༎ຶД༎ຶ`)ノ"
)
expect
(
json_response
[
'html'
]).
to
include
(
"ヾ(´༎ຶД༎ຶ`)ノ"
)
end
end
end
end
...
@@ -198,23 +198,23 @@ describe Projects::JobsController do
...
@@ -198,23 +198,23 @@ describe Projects::JobsController do
def
get_trace
def
get_trace
get
:trace
,
namespace_id:
project
.
namespace
,
get
:trace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
,
id:
job
.
id
,
format: :json
format: :json
end
end
end
end
describe
'GET status.json'
do
describe
'GET status.json'
do
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:status
)
{
build
.
detailed_status
(
double
(
'user'
))
}
let
(
:status
)
{
job
.
detailed_status
(
double
(
'user'
))
}
before
do
before
do
get
:status
,
namespace_id:
project
.
namespace
,
get
:status
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
,
id:
job
.
id
,
format: :json
format: :json
end
end
it
'return a detailed
build
status in json'
do
it
'return a detailed
job
status in json'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
json_response
[
'text'
]).
to
eq
status
.
text
expect
(
json_response
[
'text'
]).
to
eq
status
.
text
expect
(
json_response
[
'label'
]).
to
eq
status
.
label
expect
(
json_response
[
'label'
]).
to
eq
status
.
label
...
@@ -231,17 +231,17 @@ describe Projects::JobsController do
...
@@ -231,17 +231,17 @@ describe Projects::JobsController do
post_retry
post_retry
end
end
context
'when
build
is retryable'
do
context
'when
job
is retryable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:retryable
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:retryable
,
pipeline:
pipeline
)
}
it
'redirects to the retried
build
page'
do
it
'redirects to the retried
job
page'
do
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
Ci
::
Build
.
last
.
id
))
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
Ci
::
Build
.
last
.
id
))
end
end
end
end
context
'when
build
is not retryable'
do
context
'when
job
is not retryable'
do
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'renders unprocessable_entity'
do
it
'renders unprocessable_entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
...
@@ -251,7 +251,7 @@ describe Projects::JobsController do
...
@@ -251,7 +251,7 @@ describe Projects::JobsController do
def
post_retry
def
post_retry
post
:retry
,
namespace_id:
project
.
namespace
,
post
:retry
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
id:
job
.
id
end
end
end
end
...
@@ -267,21 +267,21 @@ describe Projects::JobsController do
...
@@ -267,21 +267,21 @@ describe Projects::JobsController do
post_play
post_play
end
end
context
'when
build
is playable'
do
context
'when
job
is playable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:playable
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:playable
,
pipeline:
pipeline
)
}
it
'redirects to the played
build
page'
do
it
'redirects to the played
job
page'
do
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
build
.
id
))
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
job
.
id
))
end
end
it
'transits to pending'
do
it
'transits to pending'
do
expect
(
build
.
reload
).
to
be_pending
expect
(
job
.
reload
).
to
be_pending
end
end
end
end
context
'when
build
is not playable'
do
context
'when
job
is not playable'
do
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'renders unprocessable_entity'
do
it
'renders unprocessable_entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
...
@@ -291,7 +291,7 @@ describe Projects::JobsController do
...
@@ -291,7 +291,7 @@ describe Projects::JobsController do
def
post_play
def
post_play
post
:play
,
namespace_id:
project
.
namespace
,
post
:play
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
id:
job
.
id
end
end
end
end
...
@@ -303,21 +303,21 @@ describe Projects::JobsController do
...
@@ -303,21 +303,21 @@ describe Projects::JobsController do
post_cancel
post_cancel
end
end
context
'when
build
is cancelable'
do
context
'when
job
is cancelable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:cancelable
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:cancelable
,
pipeline:
pipeline
)
}
it
'redirects to the canceled
build
page'
do
it
'redirects to the canceled
job
page'
do
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
build
.
id
))
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
job
.
id
))
end
end
it
'transits to canceled'
do
it
'transits to canceled'
do
expect
(
build
.
reload
).
to
be_canceled
expect
(
job
.
reload
).
to
be_canceled
end
end
end
end
context
'when
build
is not cancelable'
do
context
'when
job
is not cancelable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
pipeline
)
}
it
'returns unprocessable_entity'
do
it
'returns unprocessable_entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
...
@@ -327,7 +327,7 @@ describe Projects::JobsController do
...
@@ -327,7 +327,7 @@ describe Projects::JobsController do
def
post_cancel
def
post_cancel
post
:cancel
,
namespace_id:
project
.
namespace
,
post
:cancel
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
id:
job
.
id
end
end
end
end
...
@@ -337,7 +337,7 @@ describe Projects::JobsController do
...
@@ -337,7 +337,7 @@ describe Projects::JobsController do
sign_in
(
user
)
sign_in
(
user
)
end
end
context
'when
build
s are cancelable'
do
context
'when
job
s are cancelable'
do
before
do
before
do
create_list
(
:ci_build
,
2
,
:cancelable
,
pipeline:
pipeline
)
create_list
(
:ci_build
,
2
,
:cancelable
,
pipeline:
pipeline
)
...
@@ -354,7 +354,7 @@ describe Projects::JobsController do
...
@@ -354,7 +354,7 @@ describe Projects::JobsController do
end
end
end
end
context
'when
build
s are not cancelable'
do
context
'when
job
s are not cancelable'
do
before
do
before
do
create_list
(
:ci_build
,
2
,
:canceled
,
pipeline:
pipeline
)
create_list
(
:ci_build
,
2
,
:canceled
,
pipeline:
pipeline
)
...
@@ -381,26 +381,26 @@ describe Projects::JobsController do
...
@@ -381,26 +381,26 @@ describe Projects::JobsController do
post_erase
post_erase
end
end
context
'when
build
is erasable'
do
context
'when
job
is erasable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:erasable
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:erasable
,
:trace
,
pipeline:
pipeline
)
}
it
'redirects to the erased
build
page'
do
it
'redirects to the erased
job
page'
do
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
have_http_status
(
:found
)
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
build
.
id
))
expect
(
response
).
to
redirect_to
(
namespace_project_job_path
(
id:
job
.
id
))
end
end
it
'erases artifacts'
do
it
'erases artifacts'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsey
expect
(
job
.
artifacts_file
.
exists?
).
to
be_falsey
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsey
expect
(
job
.
artifacts_metadata
.
exists?
).
to
be_falsey
end
end
it
'erases trace'
do
it
'erases trace'
do
expect
(
build
.
trace
.
exist?
).
to
be_falsey
expect
(
job
.
trace
.
exist?
).
to
be_falsey
end
end
end
end
context
'when
build
is not erasable'
do
context
'when
job
is not erasable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:erased
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:erased
,
pipeline:
pipeline
)
}
it
'returns unprocessable_entity'
do
it
'returns unprocessable_entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
...
@@ -410,7 +410,7 @@ describe Projects::JobsController do
...
@@ -410,7 +410,7 @@ describe Projects::JobsController do
def
post_erase
def
post_erase
post
:erase
,
namespace_id:
project
.
namespace
,
post
:erase
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
id:
job
.
id
end
end
end
end
...
@@ -419,8 +419,8 @@ describe Projects::JobsController do
...
@@ -419,8 +419,8 @@ describe Projects::JobsController do
get_raw
get_raw
end
end
context
'when
build
has a trace file'
do
context
'when
job
has a trace file'
do
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
it
'send a trace file'
do
it
'send a trace file'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
...
@@ -429,8 +429,8 @@ describe Projects::JobsController do
...
@@ -429,8 +429,8 @@ describe Projects::JobsController do
end
end
end
end
context
'when
build
does not have a trace file'
do
context
'when
job
does not have a trace file'
do
let
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'returns not_found'
do
it
'returns not_found'
do
expect
(
response
).
to
have_http_status
(
:not_found
)
expect
(
response
).
to
have_http_status
(
:not_found
)
...
@@ -440,7 +440,7 @@ describe Projects::JobsController do
...
@@ -440,7 +440,7 @@ describe Projects::JobsController do
def
get_raw
def
get_raw
post
:raw
,
namespace_id:
project
.
namespace
,
post
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
id:
build
.
id
id:
job
.
id
end
end
end
end
end
end
spec/features/projects/jobs_spec.rb
View file @
c81db244
...
@@ -7,8 +7,8 @@ feature 'Jobs', :feature do
...
@@ -7,8 +7,8 @@ feature 'Jobs', :feature do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
build
2
)
{
create
(
:ci_build
)
}
let
(
:
job
2
)
{
create
(
:ci_build
)
}
let
(
:artifacts_file
)
do
let
(
:artifacts_file
)
do
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
...
@@ -20,7 +20,7 @@ feature 'Jobs', :feature do
...
@@ -20,7 +20,7 @@ feature 'Jobs', :feature do
end
end
describe
"GET /:project/jobs"
do
describe
"GET /:project/jobs"
do
let!
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
context
"Pending scope"
do
context
"Pending scope"
do
before
do
before
do
...
@@ -30,30 +30,30 @@ feature 'Jobs', :feature do
...
@@ -30,30 +30,30 @@ feature 'Jobs', :feature do
it
"shows Pending tab jobs"
do
it
"shows Pending tab jobs"
do
expect
(
page
).
to
have_link
'Cancel running'
expect
(
page
).
to
have_link
'Cancel running'
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'Pending'
)
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'Pending'
)
expect
(
page
).
to
have_content
build
.
short_sha
expect
(
page
).
to
have_content
job
.
short_sha
expect
(
page
).
to
have_content
build
.
ref
expect
(
page
).
to
have_content
job
.
ref
expect
(
page
).
to
have_content
build
.
name
expect
(
page
).
to
have_content
job
.
name
end
end
end
end
context
"Running scope"
do
context
"Running scope"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
,
scope: :running
)
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
,
scope: :running
)
end
end
it
"shows Running tab jobs"
do
it
"shows Running tab jobs"
do
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'Running'
)
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'Running'
)
expect
(
page
).
to
have_link
'Cancel running'
expect
(
page
).
to
have_link
'Cancel running'
expect
(
page
).
to
have_content
build
.
short_sha
expect
(
page
).
to
have_content
job
.
short_sha
expect
(
page
).
to
have_content
build
.
ref
expect
(
page
).
to
have_content
job
.
ref
expect
(
page
).
to
have_content
build
.
name
expect
(
page
).
to
have_content
job
.
name
end
end
end
end
context
"Finished scope"
do
context
"Finished scope"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
,
scope: :finished
)
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
,
scope: :finished
)
end
end
...
@@ -72,9 +72,9 @@ feature 'Jobs', :feature do
...
@@ -72,9 +72,9 @@ feature 'Jobs', :feature do
it
"shows All tab jobs"
do
it
"shows All tab jobs"
do
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'All'
)
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'All'
)
expect
(
page
).
to
have_content
build
.
short_sha
expect
(
page
).
to
have_content
job
.
short_sha
expect
(
page
).
to
have_content
build
.
ref
expect
(
page
).
to
have_content
job
.
ref
expect
(
page
).
to
have_content
build
.
name
expect
(
page
).
to
have_content
job
.
name
expect
(
page
).
not_to
have_link
'Cancel running'
expect
(
page
).
not_to
have_link
'Cancel running'
end
end
end
end
...
@@ -96,7 +96,7 @@ feature 'Jobs', :feature do
...
@@ -96,7 +96,7 @@ feature 'Jobs', :feature do
describe
"POST /:project/jobs/:id/cancel_all"
do
describe
"POST /:project/jobs/:id/cancel_all"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
)
visit
namespace_project_jobs_path
(
project
.
namespace
,
project
)
click_link
"Cancel running"
click_link
"Cancel running"
end
end
...
@@ -104,9 +104,9 @@ feature 'Jobs', :feature do
...
@@ -104,9 +104,9 @@ feature 'Jobs', :feature do
it
'shows all necessary content'
do
it
'shows all necessary content'
do
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'All'
)
expect
(
page
).
to
have_selector
(
'.nav-links li.active'
,
text:
'All'
)
expect
(
page
).
to
have_content
'canceled'
expect
(
page
).
to
have_content
'canceled'
expect
(
page
).
to
have_content
build
.
short_sha
expect
(
page
).
to
have_content
job
.
short_sha
expect
(
page
).
to
have_content
build
.
ref
expect
(
page
).
to
have_content
job
.
ref
expect
(
page
).
to
have_content
build
.
name
expect
(
page
).
to
have_content
job
.
name
expect
(
page
).
not_to
have_link
'Cancel running'
expect
(
page
).
not_to
have_link
'Cancel running'
end
end
end
end
...
@@ -114,7 +114,7 @@ feature 'Jobs', :feature do
...
@@ -114,7 +114,7 @@ feature 'Jobs', :feature do
describe
"GET /:project/jobs/:id"
do
describe
"GET /:project/jobs/:id"
do
context
"Job from project"
do
context
"Job from project"
do
before
do
before
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
'shows commit`s data'
do
it
'shows commit`s data'
do
...
@@ -124,14 +124,14 @@ feature 'Jobs', :feature do
...
@@ -124,14 +124,14 @@ feature 'Jobs', :feature do
expect
(
page
).
to
have_content
pipeline
.
git_author_name
expect
(
page
).
to
have_content
pipeline
.
git_author_name
end
end
it
'shows active
build
'
do
it
'shows active
job
'
do
expect
(
page
).
to
have_selector
(
'.build-job.active'
)
expect
(
page
).
to
have_selector
(
'.build-job.active'
)
end
end
end
end
context
"Job from other project"
do
context
"Job from other project"
do
before
do
before
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
...
@@ -139,8 +139,8 @@ feature 'Jobs', :feature do
...
@@ -139,8 +139,8 @@ feature 'Jobs', :feature do
context
"Download artifacts"
do
context
"Download artifacts"
do
before
do
before
do
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
job
.
update_attributes
(
artifacts_file:
artifacts_file
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
'has button to download artifacts'
do
it
'has button to download artifacts'
do
...
@@ -150,10 +150,10 @@ feature 'Jobs', :feature do
...
@@ -150,10 +150,10 @@ feature 'Jobs', :feature do
context
'Artifacts expire date'
do
context
'Artifacts expire date'
do
before
do
before
do
build
.
update_attributes
(
artifacts_file:
artifacts_file
,
job
.
update_attributes
(
artifacts_file:
artifacts_file
,
artifacts_expire_at:
expire_at
)
artifacts_expire_at:
expire_at
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
context
'no expire date defined'
do
context
'no expire date defined'
do
...
@@ -199,7 +199,7 @@ feature 'Jobs', :feature do
...
@@ -199,7 +199,7 @@ feature 'Jobs', :feature do
context
"when visiting old URL"
do
context
"when visiting old URL"
do
let
(
:job_url
)
do
let
(
:job_url
)
do
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
before
do
before
do
...
@@ -213,9 +213,9 @@ feature 'Jobs', :feature do
...
@@ -213,9 +213,9 @@ feature 'Jobs', :feature do
feature
'Raw trace'
do
feature
'Raw trace'
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
do
it
do
...
@@ -225,16 +225,16 @@ feature 'Jobs', :feature do
...
@@ -225,16 +225,16 @@ feature 'Jobs', :feature do
feature
'HTML trace'
,
:js
do
feature
'HTML trace'
,
:js
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
context
'when job has an initial trace'
do
context
'when job has an initial trace'
do
it
'loads job trace'
do
it
'loads job trace'
do
expect
(
page
).
to
have_content
'BUILD TRACE'
expect
(
page
).
to
have_content
'BUILD TRACE'
build
.
trace
.
write
do
|
stream
|
job
.
trace
.
write
do
|
stream
|
stream
.
append
(
' and more trace'
,
11
)
stream
.
append
(
' and more trace'
,
11
)
end
end
...
@@ -246,12 +246,12 @@ feature 'Jobs', :feature do
...
@@ -246,12 +246,12 @@ feature 'Jobs', :feature do
feature
'Variables'
do
feature
'Variables'
do
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
)
}
let
(
:
build
)
do
let
(
:
job
)
do
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
create
:ci_build
,
pipeline:
pipeline
,
trigger_request:
trigger_request
end
end
before
do
before
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
'shows variable key and value after click'
,
js:
true
do
it
'shows variable key and value after click'
,
js:
true
do
...
@@ -273,20 +273,20 @@ feature 'Jobs', :feature do
...
@@ -273,20 +273,20 @@ feature 'Jobs', :feature do
context
'job is successfull and has deployment'
do
context
'job is successfull and has deployment'
do
let
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:
build
)
{
create
(
:ci_build
,
:success
,
environment:
environment
.
name
,
deployments:
[
deployment
],
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:success
,
environment:
environment
.
name
,
deployments:
[
deployment
],
pipeline:
pipeline
)
}
it
'shows a link for the job'
do
it
'shows a link for the job'
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
expect
(
page
).
to
have_link
environment
.
name
expect
(
page
).
to
have_link
environment
.
name
end
end
end
end
context
'job is complete and not successful'
do
context
'job is complete and not successful'
do
let
(
:
build
)
{
create
(
:ci_build
,
:failed
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:failed
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
it
'shows a link for the job'
do
it
'shows a link for the job'
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
expect
(
page
).
to
have_link
environment
.
name
expect
(
page
).
to
have_link
environment
.
name
end
end
...
@@ -294,10 +294,10 @@ feature 'Jobs', :feature do
...
@@ -294,10 +294,10 @@ feature 'Jobs', :feature do
context
'job creates a new deployment'
do
context
'job creates a new deployment'
do
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
.
id
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
.
id
)
}
let
(
:
build
)
{
create
(
:ci_build
,
:success
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:success
,
environment:
environment
.
name
,
pipeline:
pipeline
)
}
it
'shows a link to latest deployment'
do
it
'shows a link to latest deployment'
do
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
expect
(
page
).
to
have_link
(
'latest deployment'
)
expect
(
page
).
to
have_link
(
'latest deployment'
)
end
end
...
@@ -308,8 +308,8 @@ feature 'Jobs', :feature do
...
@@ -308,8 +308,8 @@ feature 'Jobs', :feature do
describe
"POST /:project/jobs/:id/cancel"
do
describe
"POST /:project/jobs/:id/cancel"
do
context
"Job from project"
do
context
"Job from project"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
click_link
"Cancel"
click_link
"Cancel"
end
end
...
@@ -322,9 +322,9 @@ feature 'Jobs', :feature do
...
@@ -322,9 +322,9 @@ feature 'Jobs', :feature do
context
"Job from other project"
do
context
"Job from other project"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
page
.
driver
.
post
(
cancel_namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
))
page
.
driver
.
post
(
cancel_namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
))
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
...
@@ -334,8 +334,8 @@ feature 'Jobs', :feature do
...
@@ -334,8 +334,8 @@ feature 'Jobs', :feature do
describe
"POST /:project/jobs/:id/retry"
do
describe
"POST /:project/jobs/:id/retry"
do
context
"Job from project"
do
context
"Job from project"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
click_link
'Cancel'
click_link
'Cancel'
page
.
within
(
'.build-header'
)
do
page
.
within
(
'.build-header'
)
do
click_link
'Retry job'
click_link
'Retry job'
...
@@ -353,10 +353,10 @@ feature 'Jobs', :feature do
...
@@ -353,10 +353,10 @@ feature 'Jobs', :feature do
context
"Job from other project"
do
context
"Job from other project"
do
before
do
before
do
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
click_link
'Cancel'
click_link
'Cancel'
page
.
driver
.
post
(
retry_namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
))
page
.
driver
.
post
(
retry_namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
))
end
end
it
{
expect
(
page
).
to
have_http_status
(
404
)
}
it
{
expect
(
page
).
to
have_http_status
(
404
)
}
...
@@ -364,13 +364,13 @@ feature 'Jobs', :feature do
...
@@ -364,13 +364,13 @@ feature 'Jobs', :feature do
context
"Job that current user is not allowed to retry"
do
context
"Job that current user is not allowed to retry"
do
before
do
before
do
build
.
run!
job
.
run!
build
.
cancel!
job
.
cancel!
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
logout_direct
logout_direct
login_with
(
create
(
:user
))
login_with
(
create
(
:user
))
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
'does not show the Retry button'
do
it
'does not show the Retry button'
do
...
@@ -383,15 +383,15 @@ feature 'Jobs', :feature do
...
@@ -383,15 +383,15 @@ feature 'Jobs', :feature do
describe
"GET /:project/jobs/:id/download"
do
describe
"GET /:project/jobs/:id/download"
do
before
do
before
do
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
job
.
update_attributes
(
artifacts_file:
artifacts_file
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
click_link
'Download'
click_link
'Download'
end
end
context
"Build from other project"
do
context
"Build from other project"
do
before
do
before
do
build
2
.
update_attributes
(
artifacts_file:
artifacts_file
)
job
2
.
update_attributes
(
artifacts_file:
artifacts_file
)
visit
download_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
build
2
)
visit
download_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
2
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
...
@@ -403,23 +403,23 @@ feature 'Jobs', :feature do
...
@@ -403,23 +403,23 @@ feature 'Jobs', :feature do
context
'job from project'
do
context
'job from project'
do
before
do
before
do
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
build
.
run!
job
.
run!
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
find
(
'.js-raw-link-controller'
).
click
()
find
(
'.js-raw-link-controller'
).
click
()
end
end
it
'sends the right headers'
do
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
build
.
trace
.
send
(
:current_path
))
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
job
.
trace
.
send
(
:current_path
))
end
end
end
end
context
'job from other project'
do
context
'job from other project'
do
before
do
before
do
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
build
2
.
run!
job
2
.
run!
visit
raw_namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
)
visit
raw_namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
)
end
end
it
'sends the right headers'
do
it
'sends the right headers'
do
...
@@ -434,15 +434,15 @@ feature 'Jobs', :feature do
...
@@ -434,15 +434,15 @@ feature 'Jobs', :feature do
before
do
before
do
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
Capybara
.
current_session
.
driver
.
headers
=
{
'X-Sendfile-Type'
=>
'X-Sendfile'
}
build
.
run!
job
.
run!
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:paths
)
allow_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
to
receive
(
:paths
)
.
and_return
(
paths
)
.
and_return
(
paths
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
context
'when
build
has trace in file'
,
:js
do
context
'when
job
has trace in file'
,
:js
do
let
(
:paths
)
do
let
(
:paths
)
do
[
existing_file
]
[
existing_file
]
end
end
...
@@ -469,7 +469,7 @@ feature 'Jobs', :feature do
...
@@ -469,7 +469,7 @@ feature 'Jobs', :feature do
context
"when visiting old URL"
do
context
"when visiting old URL"
do
let
(
:raw_job_url
)
do
let
(
:raw_job_url
)
do
raw_namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
raw_namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
before
do
before
do
...
@@ -485,7 +485,7 @@ feature 'Jobs', :feature do
...
@@ -485,7 +485,7 @@ feature 'Jobs', :feature do
describe
"GET /:project/jobs/:id/trace.json"
do
describe
"GET /:project/jobs/:id/trace.json"
do
context
"Job from project"
do
context
"Job from project"
do
before
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build
,
format: :json
)
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
job
,
format: :json
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
...
@@ -493,7 +493,7 @@ feature 'Jobs', :feature do
...
@@ -493,7 +493,7 @@ feature 'Jobs', :feature do
context
"Job from other project"
do
context
"Job from other project"
do
before
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
,
format: :json
)
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
,
format: :json
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
...
@@ -503,7 +503,7 @@ feature 'Jobs', :feature do
...
@@ -503,7 +503,7 @@ feature 'Jobs', :feature do
describe
"GET /:project/jobs/:id/status"
do
describe
"GET /:project/jobs/:id/status"
do
context
"Job from project"
do
context
"Job from project"
do
before
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
job
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
...
@@ -511,7 +511,7 @@ feature 'Jobs', :feature do
...
@@ -511,7 +511,7 @@ feature 'Jobs', :feature do
context
"Job from other project"
do
context
"Job from other project"
do
before
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build
2
)
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
job
2
)
end
end
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
404
)
}
...
...
spec/requests/api/jobs_spec.rb
View file @
c81db244
...
@@ -11,7 +11,7 @@ describe API::Jobs, :api do
...
@@ -11,7 +11,7 @@ describe API::Jobs, :api do
ref:
project
.
default_branch
)
ref:
project
.
default_branch
)
end
end
let!
(
:
build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:api_user
)
{
user
}
let
(
:api_user
)
{
user
}
...
@@ -42,13 +42,13 @@ describe API::Jobs, :api do
...
@@ -42,13 +42,13 @@ describe API::Jobs, :api do
end
end
it
'returns pipeline data'
do
it
'returns pipeline data'
do
json_
build
=
json_response
.
first
json_
job
=
json_response
.
first
expect
(
json_
build
[
'pipeline'
]).
not_to
be_empty
expect
(
json_
job
[
'pipeline'
]).
not_to
be_empty
expect
(
json_
build
[
'pipeline'
][
'id'
]).
to
eq
build
.
pipeline
.
id
expect
(
json_
job
[
'pipeline'
][
'id'
]).
to
eq
job
.
pipeline
.
id
expect
(
json_
build
[
'pipeline'
][
'ref'
]).
to
eq
build
.
pipeline
.
ref
expect
(
json_
job
[
'pipeline'
][
'ref'
]).
to
eq
job
.
pipeline
.
ref
expect
(
json_
build
[
'pipeline'
][
'sha'
]).
to
eq
build
.
pipeline
.
sha
expect
(
json_
job
[
'pipeline'
][
'sha'
]).
to
eq
job
.
pipeline
.
sha
expect
(
json_
build
[
'pipeline'
][
'status'
]).
to
eq
build
.
pipeline
.
status
expect
(
json_
job
[
'pipeline'
][
'status'
]).
to
eq
job
.
pipeline
.
status
end
end
context
'filter project with one scope element'
do
context
'filter project with one scope element'
do
...
@@ -79,7 +79,7 @@ describe API::Jobs, :api do
...
@@ -79,7 +79,7 @@ describe API::Jobs, :api do
context
'unauthorized user'
do
context
'unauthorized user'
do
let
(
:api_user
)
{
nil
}
let
(
:api_user
)
{
nil
}
it
'does not return project
build
s'
do
it
'does not return project
job
s'
do
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
end
end
...
@@ -105,13 +105,13 @@ describe API::Jobs, :api do
...
@@ -105,13 +105,13 @@ describe API::Jobs, :api do
end
end
it
'returns pipeline data'
do
it
'returns pipeline data'
do
json_
build
=
json_response
.
first
json_
job
=
json_response
.
first
expect
(
json_
build
[
'pipeline'
]).
not_to
be_empty
expect
(
json_
job
[
'pipeline'
]).
not_to
be_empty
expect
(
json_
build
[
'pipeline'
][
'id'
]).
to
eq
build
.
pipeline
.
id
expect
(
json_
job
[
'pipeline'
][
'id'
]).
to
eq
job
.
pipeline
.
id
expect
(
json_
build
[
'pipeline'
][
'ref'
]).
to
eq
build
.
pipeline
.
ref
expect
(
json_
job
[
'pipeline'
][
'ref'
]).
to
eq
job
.
pipeline
.
ref
expect
(
json_
build
[
'pipeline'
][
'sha'
]).
to
eq
build
.
pipeline
.
sha
expect
(
json_
job
[
'pipeline'
][
'sha'
]).
to
eq
job
.
pipeline
.
sha
expect
(
json_
build
[
'pipeline'
][
'status'
]).
to
eq
build
.
pipeline
.
status
expect
(
json_
job
[
'pipeline'
][
'status'
]).
to
eq
job
.
pipeline
.
status
end
end
context
'filter jobs with one scope element'
do
context
'filter jobs with one scope element'
do
...
@@ -140,7 +140,7 @@ describe API::Jobs, :api do
...
@@ -140,7 +140,7 @@ describe API::Jobs, :api do
context
'jobs in different pipelines'
do
context
'jobs in different pipelines'
do
let!
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let!
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let!
(
:
build
2
)
{
create
(
:ci_build
,
pipeline:
pipeline2
)
}
let!
(
:
job
2
)
{
create
(
:ci_build
,
pipeline:
pipeline2
)
}
it
'excludes jobs from other pipelines'
do
it
'excludes jobs from other pipelines'
do
json_response
.
each
{
|
job
|
expect
(
job
[
'pipeline'
][
'id'
]).
to
eq
(
pipeline
.
id
)
}
json_response
.
each
{
|
job
|
expect
(
job
[
'pipeline'
][
'id'
]).
to
eq
(
pipeline
.
id
)
}
...
@@ -159,7 +159,7 @@ describe API::Jobs, :api do
...
@@ -159,7 +159,7 @@ describe API::Jobs, :api do
describe
'GET /projects/:id/jobs/:job_id'
do
describe
'GET /projects/:id/jobs/:job_id'
do
before
do
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
"
,
api_user
)
end
end
context
'authorized user'
do
context
'authorized user'
do
...
@@ -169,12 +169,13 @@ describe API::Jobs, :api do
...
@@ -169,12 +169,13 @@ describe API::Jobs, :api do
end
end
it
'returns pipeline data'
do
it
'returns pipeline data'
do
json_build
=
json_response
json_job
=
json_response
expect
(
json_build
[
'pipeline'
]).
not_to
be_empty
expect
(
json_build
[
'pipeline'
][
'id'
]).
to
eq
build
.
pipeline
.
id
expect
(
json_job
[
'pipeline'
]).
not_to
be_empty
expect
(
json_build
[
'pipeline'
][
'ref'
]).
to
eq
build
.
pipeline
.
ref
expect
(
json_job
[
'pipeline'
][
'id'
]).
to
eq
job
.
pipeline
.
id
expect
(
json_build
[
'pipeline'
][
'sha'
]).
to
eq
build
.
pipeline
.
sha
expect
(
json_job
[
'pipeline'
][
'ref'
]).
to
eq
job
.
pipeline
.
ref
expect
(
json_build
[
'pipeline'
][
'status'
]).
to
eq
build
.
pipeline
.
status
expect
(
json_job
[
'pipeline'
][
'sha'
]).
to
eq
job
.
pipeline
.
sha
expect
(
json_job
[
'pipeline'
][
'status'
]).
to
eq
job
.
pipeline
.
status
end
end
end
end
...
@@ -189,11 +190,11 @@ describe API::Jobs, :api do
...
@@ -189,11 +190,11 @@ describe API::Jobs, :api do
describe
'GET /projects/:id/jobs/:job_id/artifacts'
do
describe
'GET /projects/:id/jobs/:job_id/artifacts'
do
before
do
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/artifacts"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
end
context
'job with artifacts'
do
context
'job with artifacts'
do
let
(
:
build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
context
'authorized user'
do
context
'authorized user'
do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
...
@@ -204,7 +205,7 @@ describe API::Jobs, :api do
...
@@ -204,7 +205,7 @@ describe API::Jobs, :api do
it
'returns specific job artifacts'
do
it
'returns specific job artifacts'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
.
headers
).
to
include
(
download_headers
)
expect
(
response
.
headers
).
to
include
(
download_headers
)
expect
(
response
.
body
).
to
match_file
(
build
.
artifacts_file
.
file
.
file
)
expect
(
response
.
body
).
to
match_file
(
job
.
artifacts_file
.
file
.
file
)
end
end
end
end
...
@@ -224,14 +225,14 @@ describe API::Jobs, :api do
...
@@ -224,14 +225,14 @@ describe API::Jobs, :api do
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
}
let
(
:api_user
)
{
reporter
}
let
(
:
build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
before
do
build
.
success
job
.
success
end
end
def
get_for_ref
(
ref
=
pipeline
.
ref
,
job
=
build
.
name
)
def
get_for_ref
(
ref
=
pipeline
.
ref
,
job
_name
=
job
.
name
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/artifacts/
#{
ref
}
/download"
,
api_user
),
job:
job
get
api
(
"/projects/
#{
project
.
id
}
/jobs/artifacts/
#{
ref
}
/download"
,
api_user
),
job:
job
_name
end
end
context
'when not logged in'
do
context
'when not logged in'
do
...
@@ -285,7 +286,7 @@ describe API::Jobs, :api do
...
@@ -285,7 +286,7 @@ describe API::Jobs, :api do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'Content-Disposition'
=>
"attachment; filename=
#{
build
.
artifacts_file
.
filename
}
"
}
"attachment; filename=
#{
job
.
artifacts_file
.
filename
}
"
}
end
end
it
{
expect
(
response
).
to
have_http_status
(
200
)
}
it
{
expect
(
response
).
to
have_http_status
(
200
)
}
...
@@ -321,16 +322,16 @@ describe API::Jobs, :api do
...
@@ -321,16 +322,16 @@ describe API::Jobs, :api do
end
end
describe
'GET /projects/:id/jobs/:job_id/trace'
do
describe
'GET /projects/:id/jobs/:job_id/trace'
do
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
before
do
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/trace"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/trace"
,
api_user
)
end
end
context
'authorized user'
do
context
'authorized user'
do
it
'returns specific job trace'
do
it
'returns specific job trace'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
build
.
trace
.
raw
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
end
end
end
end
...
@@ -345,7 +346,7 @@ describe API::Jobs, :api do
...
@@ -345,7 +346,7 @@ describe API::Jobs, :api do
describe
'POST /projects/:id/jobs/:job_id/cancel'
do
describe
'POST /projects/:id/jobs/:job_id/cancel'
do
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/cancel"
,
api_user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/cancel"
,
api_user
)
end
end
context
'authorized user'
do
context
'authorized user'
do
...
@@ -375,10 +376,10 @@ describe API::Jobs, :api do
...
@@ -375,10 +376,10 @@ describe API::Jobs, :api do
end
end
describe
'POST /projects/:id/jobs/:job_id/retry'
do
describe
'POST /projects/:id/jobs/:job_id/retry'
do
let
(
:
build
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
pipeline
)
}
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/retry"
,
api_user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/retry"
,
api_user
)
end
end
context
'authorized user'
do
context
'authorized user'
do
...
@@ -410,28 +411,29 @@ describe API::Jobs, :api do
...
@@ -410,28 +411,29 @@ describe API::Jobs, :api do
describe
'POST /projects/:id/jobs/:job_id/erase'
do
describe
'POST /projects/:id/jobs/:job_id/erase'
do
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/erase"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/erase"
,
user
)
end
end
context
'job is erasable'
do
context
'job is erasable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
)
}
it
'erases job content'
do
it
'erases job content'
do
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
build
).
not_to
have_trace
expect
(
job
).
not_to
have_trace
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
job
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
expect
(
job
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
end
it
'updates job'
do
it
'updates job'
do
build
.
reload
job
.
reload
expect
(
build
.
erased_at
).
to
be_truthy
expect
(
build
.
erased_by
).
to
eq
(
user
)
expect
(
job
.
erased_at
).
to
be_truthy
expect
(
job
.
erased_by
).
to
eq
(
user
)
end
end
end
end
context
'job is not erasable'
do
context
'job is not erasable'
do
let
(
:
build
)
{
create
(
:ci_build
,
:trace
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:trace
,
project:
project
,
pipeline:
pipeline
)
}
it
'responds with forbidden'
do
it
'responds with forbidden'
do
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
...
@@ -439,25 +441,25 @@ describe API::Jobs, :api do
...
@@ -439,25 +441,25 @@ describe API::Jobs, :api do
end
end
end
end
describe
'POST /projects/:id/jobs/:
build
_id/artifacts/keep'
do
describe
'POST /projects/:id/jobs/:
job
_id/artifacts/keep'
do
before
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
build
.
id
}
/artifacts/keep"
,
user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts/keep"
,
user
)
end
end
context
'artifacts did not expire'
do
context
'artifacts did not expire'
do
let
(
:
build
)
do
let
(
:
job
)
do
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
project:
project
,
pipeline:
pipeline
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
end
end
it
'keeps artifacts'
do
it
'keeps artifacts'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
build
.
reload
.
artifacts_expire_at
).
to
be_nil
expect
(
job
.
reload
.
artifacts_expire_at
).
to
be_nil
end
end
end
end
context
'no artifacts'
do
context
'no artifacts'
do
let
(
:
build
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:
job
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
it
'responds with not found'
do
it
'responds with not found'
do
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
...
@@ -467,18 +469,18 @@ describe API::Jobs, :api do
...
@@ -467,18 +469,18 @@ describe API::Jobs, :api 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"
,
api_user
)
post
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
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
(
:
job
)
{
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
pipeline
)
}
context
'when user is authorized to trigger a manual action'
do
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
(
job
.
id
)
expect
(
build
.
reload
).
to
be_pending
expect
(
job
.
reload
).
to
be_pending
end
end
end
end
...
@@ -487,7 +489,7 @@ describe API::Jobs, :api do
...
@@ -487,7 +489,7 @@ describe API::Jobs, :api do
let
(
:api_user
)
{
create
(
:user
)
}
let
(
:api_user
)
{
create
(
:user
)
}
it
'does not trigger a manual action'
do
it
'does not trigger a manual action'
do
expect
(
build
.
reload
).
to
be_manual
expect
(
job
.
reload
).
to
be_manual
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
end
...
@@ -496,7 +498,7 @@ describe API::Jobs, :api do
...
@@ -496,7 +498,7 @@ describe API::Jobs, :api do
let
(
:api_user
)
{
reporter
}
let
(
:api_user
)
{
reporter
}
it
'does not trigger a manual action'
do
it
'does not trigger a manual action'
do
expect
(
build
.
reload
).
to
be_manual
expect
(
job
.
reload
).
to
be_manual
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
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