Commit 4131a49b authored by Semyon Pupkov's avatar Semyon Pupkov

Expose artifacts_expire_at field for job entity in api

https://gitlab.com/gitlab-org/gitlab-ce/issues/45798
parent de12348e
---
title: Expose artifacts_expire_at field for job entity in api
merge_request: 18872
author: Semyon Pupkov
type: added
......@@ -38,6 +38,7 @@ Example of response
"size": 1000
},
"finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z"
"id": 7,
"name": "teaspoon",
"pipeline": {
......@@ -81,6 +82,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null,
"finished_at": "2015-12-24T17:54:24.921Z",
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"id": 6,
"name": "rspec:other",
"pipeline": {
......@@ -152,6 +154,7 @@ Example of response
"size": 1000
},
"finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z"
"id": 7,
"name": "teaspoon",
"pipeline": {
......@@ -195,6 +198,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null,
"finished_at": "2015-12-24T17:54:24.921Z",
"artifacts_expire_at": "2016-01-23T17:54:24.921Z"
"id": 6,
"name": "rspec:other",
"pipeline": {
......@@ -261,6 +265,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.880Z",
"artifacts_file": null,
"finished_at": "2015-12-24T17:54:31.198Z",
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
"id": 8,
"name": "rubocop",
"pipeline": {
......
......@@ -1020,6 +1020,7 @@ module API
class Job < JobBasic
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :runner, with: Runner
expose :artifacts_expire_at
end
class JobBasicWithProject < JobBasic
......
......@@ -13,7 +13,10 @@ describe API::Jobs do
ref: project.default_branch)
end
let!(:job) { create(:ci_build, :success, pipeline: pipeline) }
let!(:job) do
create(:ci_build, :success, pipeline: pipeline,
artifacts_expire_at: 1.day.since)
end
let(:user) { create(:user) }
let(:api_user) { user }
......@@ -43,6 +46,7 @@ describe API::Jobs do
it 'returns correct values' do
expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id
expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
end
it 'returns pipeline data' do
......@@ -128,6 +132,7 @@ describe API::Jobs do
it 'returns correct values' do
expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id
expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
end
it 'returns pipeline data' do
......@@ -201,6 +206,7 @@ describe API::Jobs do
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(Time.parse(json_response['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
expect(json_response['duration']).to eq(job.duration)
end
......
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