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
32c50f7e
Commit
32c50f7e
authored
Feb 02, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish all tests
parent
efd30ba5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
28 deletions
+82
-28
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+22
-1
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+30
-14
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+2
-2
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+19
-8
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+9
-3
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
32c50f7e
...
...
@@ -159,6 +159,17 @@ describe Projects::JobsController do
get_trace
end
context
'when job has a trace artifact'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace_artifact
,
pipeline:
pipeline
)
}
it
'returns a trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'id'
]).
to
eq
job
.
id
expect
(
json_response
[
'status'
]).
to
eq
job
.
status
expect
(
json_response
[
'html'
]).
to
eq
(
job
.
trace
.
html
)
end
end
context
'when job has a trace'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
...
...
@@ -381,7 +392,7 @@ describe Projects::JobsController do
end
context
'when job is erasable'
do
let
(
:job
)
{
create
(
:ci_build
,
:erasable
,
:trace
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:erasable
,
:trace
,
:trace_artifact
,
pipeline:
pipeline
)
}
it
'redirects to the erased job page'
do
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
...
...
@@ -439,6 +450,16 @@ describe Projects::JobsController do
get_raw
end
context
'when job has a trace artifact'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace_artifact
,
pipeline:
pipeline
)
}
it
'returns a trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
content_type
).
to
eq
'text/plain; charset=utf-8'
expect
(
response
.
body
).
to
eq
job
.
job_artifacts_trace
.
open
.
read
end
end
context
'when job has a trace file'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
...
...
spec/features/projects/jobs_spec.rb
View file @
32c50f7e
...
...
@@ -272,13 +272,13 @@ feature 'Jobs' do
end
feature
'HTML trace'
,
:js
do
before
do
job
.
run!
context
'when job is running'
do
before
do
job
.
run!
visit
project_job_path
(
project
,
job
)
end
visit
project_job_path
(
project
,
job
)
end
context
'when job has an initial trace'
do
it
'loads job trace'
do
expect
(
page
).
to
have_content
'BUILD TRACE'
...
...
@@ -490,18 +490,34 @@ feature 'Jobs' do
describe
'GET /:project/jobs/:id/raw'
,
:js
do
context
'access source'
do
context
'job from project'
do
before
do
job
.
run!
end
context
'when job is running'
do
before
do
job
.
run!
end
it
'sends the right headers'
do
requests
=
inspect_requests
(
inject_headers:
{
'X-Sendfile-Type'
=>
'X-Sendfile'
})
do
visit
raw_project_job_path
(
project
,
job
)
it
'sends the right headers'
do
requests
=
inspect_requests
(
inject_headers:
{
'X-Sendfile-Type'
=>
'X-Sendfile'
})
do
visit
raw_project_job_path
(
project
,
job
)
end
expect
(
requests
.
first
.
status_code
).
to
eq
(
200
)
expect
(
requests
.
first
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
requests
.
first
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
job
.
trace
.
send
(
:current_path
))
end
end
expect
(
requests
.
first
.
status_code
).
to
eq
(
200
)
expect
(
requests
.
first
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
requests
.
first
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
job
.
trace
.
send
(
:current_path
))
context
'when job is complete'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
pipeline:
pipeline
)
}
it
'sends the right headers'
do
requests
=
inspect_requests
(
inject_headers:
{
'X-Sendfile-Type'
=>
'X-Sendfile'
})
do
visit
raw_project_job_path
(
project
,
job
)
end
expect
(
requests
.
first
.
status_code
).
to
eq
(
200
)
expect
(
requests
.
first
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
requests
.
first
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
job
.
job_artifacts_trace
.
file
.
path
)
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
32c50f7e
...
...
@@ -675,7 +675,7 @@ describe Ci::Build do
context
'build is erasable'
do
context
'new artifacts'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:
trace_artifact
,
:
success
,
:artifacts
)
}
describe
'#erase'
do
before
do
...
...
@@ -709,7 +709,7 @@ describe Ci::Build do
end
describe
'#erased?'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:
trace_artifact
,
:
success
,
:artifacts
)
}
subject
{
build
.
erased?
}
context
'job has not been erased'
do
...
...
spec/requests/api/jobs_spec.rb
View file @
32c50f7e
...
...
@@ -446,16 +446,27 @@ describe API::Jobs do
end
describe
'GET /projects/:id/jobs/:job_id/trace'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/trace"
,
api_user
)
end
context
'authorized user'
do
it
'returns specific job trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
context
'when trace is artifact'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace_artifact
,
pipeline:
pipeline
)
}
it
'returns specific job trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
end
end
context
'when trace is file'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
it
'returns specific job trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
end
end
end
...
...
@@ -543,11 +554,11 @@ describe API::Jobs do
end
context
'job is erasable'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
:
trace_artifact
,
:
artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
)
}
it
'erases job content'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
job
).
not_to
have_trace
expect
(
job
.
trace
.
exist?
).
to
be_falsy
expect
(
job
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
job
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
...
...
@@ -570,7 +581,7 @@ describe API::Jobs do
context
'when a developer erases a build'
do
let
(
:role
)
{
:developer
}
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
,
user:
owner
)
}
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
:
trace_artifact
,
:
artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
,
user:
owner
)
}
context
'when the build was created by the developer'
do
let
(
:owner
)
{
user
}
...
...
spec/requests/api/runner_spec.rb
View file @
32c50f7e
...
...
@@ -680,11 +680,17 @@ describe API::Runner do
end
context
'when tace is given'
do
it
'updates a running build'
do
update_job
(
trace:
'BUILD TRACE UPDATED'
)
it
'creates a trace artifact'
do
allow_any_instance_of
(
BuildFinishedWorker
).
to
receive
(
:perform
).
with
(
job
.
id
)
do
CreateTraceArtifactWorker
.
new
.
perform
(
job
.
id
)
end
update_job
(
state:
'success'
,
trace:
'BUILD TRACE UPDATED'
)
job
.
reload
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
job
.
reload
.
trace
.
raw
).
to
eq
'BUILD TRACE UPDATED'
expect
(
job
.
trace
.
raw
).
to
eq
'BUILD TRACE UPDATED'
expect
(
job
.
job_artifacts_trace
.
open
.
read
).
to
eq
'BUILD TRACE UPDATED'
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