diff options
author | Steve Azzopardi <steveazz@outlook.com> | 2018-09-27 09:04:51 +0200 |
---|---|---|
committer | Steve Azzopardi <steveazz@outlook.com> | 2018-09-27 11:40:50 +0200 |
commit | 0599a25f9570d7af2c0b76c4165612962a9ccd85 (patch) | |
tree | 533bd3556dd80d70b0def83b8bbe8a2e95b5f742 | |
parent | c052f5a942152982124315791aad10da5fec11d5 (diff) | |
download | gitlab-ce-0599a25f9570d7af2c0b76c4165612962a9ccd85.tar.gz |
Add has_trace to Projects::JobController#show.json
closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51925
4 files changed, 27 insertions, 1 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 00a441a9a1e..c85b1790e73 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -7,6 +7,7 @@ class BuildDetailsEntity < JobEntity expose :coverage, :erased_at, :duration expose :tag_list, as: :tags + expose :has_trace?, as: :has_trace expose :user, using: UserEntity expose :runner, using: RunnerEntity expose :pipeline, using: PipelineEntity diff --git a/changelogs/unreleased/51925-expose-has_trace-in-job-api.yml b/changelogs/unreleased/51925-expose-has_trace-in-job-api.yml new file mode 100644 index 00000000000..eade86d97ac --- /dev/null +++ b/changelogs/unreleased/51925-expose-has_trace-in-job-api.yml @@ -0,0 +1,5 @@ +--- +title: Expose has_trace in job API +merge_request: 21950 +author: +type: other diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index c82c85970dc..fd11cb31a2a 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -337,6 +337,22 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do end end end + + context 'when no trace is available' do + it 'has_trace is false' do + expect(response).to match_response_schema('job/job_details') + expect(json_response['has_trace']).to be false + end + end + + context 'when job has trace' do + let(:job) { create(:ci_build, :running, :trace_live, pipeline: pipeline) } + + it "has_trace is true" do + expect(response).to match_response_schema('job/job_details') + expect(json_response['has_trace']).to be true + end + end end context 'when requesting JSON job is triggered' do diff --git a/spec/fixtures/api/schemas/job/job_details.json b/spec/fixtures/api/schemas/job/job_details.json index cd67d3e4160..70d59c6e621 100644 --- a/spec/fixtures/api/schemas/job/job_details.json +++ b/spec/fixtures/api/schemas/job/job_details.json @@ -3,12 +3,16 @@ { "$ref": "job.json" } ], "description": "An extension of job.json with more detailed information", + "required": [ + "has_trace" + ], "properties": { "artifact": { "$ref": "artifact.json" }, "terminal_path": { "type": "string" }, "trigger": { "$ref": "trigger.json" }, "deployment_status": { "$ref": "deployment_status.json" }, "runner": { "$ref": "runner.json" }, - "runners": { "type": "runners.json" } + "runners": { "type": "runners.json" }, + "has_trace": { "type": "boolean" } } } |