summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Azzopardi <steveazz@outlook.com>2018-09-27 09:04:51 +0200
committerSteve Azzopardi <steveazz@outlook.com>2018-09-27 09:11:39 +0200
commit38496cff842b4907cefb7c90338dfa16d48d41c3 (patch)
treef577df9cd38ab615b9474282d68d73d245a0bf08
parentc052f5a942152982124315791aad10da5fec11d5 (diff)
downloadgitlab-ce-51925-expose-has_trace-in-job-api.tar.gz
Add has_trace to Projects::JobController#show.json51925-expose-has_trace-in-job-api
closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51925
-rw-r--r--app/serializers/build_details_entity.rb4
-rw-r--r--changelogs/unreleased/51925-expose-has_trace-in-job-api.yml5
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb16
-rw-r--r--spec/fixtures/api/schemas/job/job_details.json6
4 files changed, 30 insertions, 1 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 00a441a9a1e..ef844182818 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -93,6 +93,10 @@ class BuildDetailsEntity < JobEntity
end
end
+ expose :has_trace do |build|
+ build.has_trace?
+ end
+
private
def build_failed_issue_options
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" }
}
}