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
1
Merge Requests
1
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
nexedi
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
Show 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
...
@@ -159,6 +159,17 @@ describe Projects::JobsController do
get_trace
get_trace
end
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
context
'when job has a trace'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
...
@@ -381,7 +392,7 @@ describe Projects::JobsController do
...
@@ -381,7 +392,7 @@ describe Projects::JobsController do
end
end
context
'when job is erasable'
do
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
it
'redirects to the erased job page'
do
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
...
@@ -439,6 +450,16 @@ describe Projects::JobsController do
...
@@ -439,6 +450,16 @@ describe Projects::JobsController do
get_raw
get_raw
end
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
context
'when job has a trace file'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
...
...
spec/features/projects/jobs_spec.rb
View file @
32c50f7e
...
@@ -272,13 +272,13 @@ feature 'Jobs' do
...
@@ -272,13 +272,13 @@ feature 'Jobs' do
end
end
feature
'HTML trace'
,
:js
do
feature
'HTML trace'
,
:js
do
context
'when job is running'
do
before
do
before
do
job
.
run!
job
.
run!
visit
project_job_path
(
project
,
job
)
visit
project_job_path
(
project
,
job
)
end
end
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'
...
@@ -490,6 +490,7 @@ feature 'Jobs' do
...
@@ -490,6 +490,7 @@ feature 'Jobs' do
describe
'GET /:project/jobs/:id/raw'
,
:js
do
describe
'GET /:project/jobs/:id/raw'
,
:js
do
context
'access source'
do
context
'access source'
do
context
'job from project'
do
context
'job from project'
do
context
'when job is running'
do
before
do
before
do
job
.
run!
job
.
run!
end
end
...
@@ -505,6 +506,21 @@ feature 'Jobs' do
...
@@ -505,6 +506,21 @@ feature 'Jobs' do
end
end
end
end
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
context
'job from other project'
do
context
'job from other project'
do
before
do
before
do
job2
.
run!
job2
.
run!
...
...
spec/models/ci/build_spec.rb
View file @
32c50f7e
...
@@ -675,7 +675,7 @@ describe Ci::Build do
...
@@ -675,7 +675,7 @@ describe Ci::Build do
context
'build is erasable'
do
context
'build is erasable'
do
context
'new artifacts'
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
describe
'#erase'
do
before
do
before
do
...
@@ -709,7 +709,7 @@ describe Ci::Build do
...
@@ -709,7 +709,7 @@ describe Ci::Build do
end
end
describe
'#erased?'
do
describe
'#erased?'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:
trace_artifact
,
:
success
,
:artifacts
)
}
subject
{
build
.
erased?
}
subject
{
build
.
erased?
}
context
'job has not been erased'
do
context
'job has not been erased'
do
...
...
spec/requests/api/jobs_spec.rb
View file @
32c50f7e
...
@@ -446,18 +446,29 @@ describe API::Jobs do
...
@@ -446,18 +446,29 @@ describe API::Jobs do
end
end
describe
'GET /projects/:id/jobs/:job_id/trace'
do
describe
'GET /projects/:id/jobs/:job_id/trace'
do
let
(
:job
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
before
do
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
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
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
it
'returns specific job trace'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
expect
(
response
.
body
).
to
eq
(
job
.
trace
.
raw
)
end
end
end
end
end
context
'unauthorized user'
do
context
'unauthorized user'
do
let
(
:api_user
)
{
nil
}
let
(
:api_user
)
{
nil
}
...
@@ -543,11 +554,11 @@ describe API::Jobs do
...
@@ -543,11 +554,11 @@ describe API::Jobs do
end
end
context
'job is erasable'
do
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
it
'erases job content'
do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
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_file
.
exists?
).
to
be_falsy
expect
(
job
.
artifacts_metadata
.
exists?
).
to
be_falsy
expect
(
job
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
end
...
@@ -570,7 +581,7 @@ describe API::Jobs do
...
@@ -570,7 +581,7 @@ describe API::Jobs do
context
'when a developer erases a build'
do
context
'when a developer erases a build'
do
let
(
:role
)
{
:developer
}
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
context
'when the build was created by the developer'
do
let
(
:owner
)
{
user
}
let
(
:owner
)
{
user
}
...
...
spec/requests/api/runner_spec.rb
View file @
32c50f7e
...
@@ -680,11 +680,17 @@ describe API::Runner do
...
@@ -680,11 +680,17 @@ describe API::Runner do
end
end
context
'when tace is given'
do
context
'when tace is given'
do
it
'updates a running build'
do
it
'creates a trace artifact'
do
update_job
(
trace:
'BUILD TRACE UPDATED'
)
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
(
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
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