Commit 08bc2f94 authored by Mehdi Lahmam's avatar Mehdi Lahmam

Expose `duration` in Job API entity

Closes #35794.
parent 1d5f2f9c
---
title: Expose duration in Job entity
merge_request: 13644
author: Mehdi Lahmam (@mehlah)
type: added
...@@ -822,6 +822,7 @@ module API ...@@ -822,6 +822,7 @@ module API
class Job < Grape::Entity class Job < Grape::Entity
expose :id, :status, :stage, :name, :ref, :tag, :coverage expose :id, :status, :stage, :name, :ref, :tag, :coverage
expose :created_at, :started_at, :finished_at expose :created_at, :started_at, :finished_at
expose :duration
expose :user, with: User expose :user, with: User
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? } expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :commit, with: Commit expose :commit, with: Commit
......
...@@ -165,7 +165,17 @@ describe API::Jobs do ...@@ -165,7 +165,17 @@ describe API::Jobs do
context 'authorized user' do context 'authorized user' do
it 'returns specific job data' do it 'returns specific job data' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['name']).to eq('test') expect(json_response['id']).to eq(job.id)
expect(json_response['status']).to eq(job.status)
expect(json_response['stage']).to eq(job.stage)
expect(json_response['name']).to eq(job.name)
expect(json_response['ref']).to eq(job.ref)
expect(json_response['tag']).to eq(job.tag)
expect(json_response['coverage']).to eq(job.coverage)
expect(Time.parse(json_response['created_at'])).to be_like_time(job.created_at)
expect(Time.parse(json_response['started_at'])).to be_like_time(job.started_at)
expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at)
expect(json_response['duration']).to eq(job.duration)
end end
it 'returns pipeline data' do it 'returns pipeline data' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment