Commit 0713188b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'expose-job-duration' into 'master'

Expose `duration` in Job API entity

Closes #35794

See merge request gitlab-org/gitlab-ce!13644
parents a2cd9ad2 08bc2f94
---
title: Expose duration in Job entity
merge_request: 13644
author: Mehdi Lahmam (@mehlah)
type: added
......@@ -822,6 +822,7 @@ module API
class Job < Grape::Entity
expose :id, :status, :stage, :name, :ref, :tag, :coverage
expose :created_at, :started_at, :finished_at
expose :duration
expose :user, with: User
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :commit, with: Commit
......
......@@ -165,7 +165,17 @@ describe API::Jobs do
context 'authorized user' do
it 'returns specific job data' do
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
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