Commit 6b7a70d2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'add-artifacts_expire_at-to-api' into 'master'

Expose artifacts_expire_at field for job entity in api

See merge request gitlab-org/gitlab-ce!18872
parents 43ec52ab 4131a49b
---
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 ...@@ -38,6 +38,7 @@ Example of response
"size": 1000 "size": 1000
}, },
"finished_at": "2015-12-24T17:54:27.895Z", "finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z"
"id": 7, "id": 7,
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
...@@ -81,6 +82,7 @@ Example of response ...@@ -81,6 +82,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z", "created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2015-12-24T17:54:24.921Z", "finished_at": "2015-12-24T17:54:24.921Z",
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"id": 6, "id": 6,
"name": "rspec:other", "name": "rspec:other",
"pipeline": { "pipeline": {
...@@ -152,6 +154,7 @@ Example of response ...@@ -152,6 +154,7 @@ Example of response
"size": 1000 "size": 1000
}, },
"finished_at": "2015-12-24T17:54:27.895Z", "finished_at": "2015-12-24T17:54:27.895Z",
"artifacts_expire_at": "2016-01-23T17:54:27.895Z"
"id": 7, "id": 7,
"name": "teaspoon", "name": "teaspoon",
"pipeline": { "pipeline": {
...@@ -195,6 +198,7 @@ Example of response ...@@ -195,6 +198,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.727Z", "created_at": "2015-12-24T15:51:21.727Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2015-12-24T17:54:24.921Z", "finished_at": "2015-12-24T17:54:24.921Z",
"artifacts_expire_at": "2016-01-23T17:54:24.921Z"
"id": 6, "id": 6,
"name": "rspec:other", "name": "rspec:other",
"pipeline": { "pipeline": {
...@@ -261,6 +265,7 @@ Example of response ...@@ -261,6 +265,7 @@ Example of response
"created_at": "2015-12-24T15:51:21.880Z", "created_at": "2015-12-24T15:51:21.880Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2015-12-24T17:54:31.198Z", "finished_at": "2015-12-24T17:54:31.198Z",
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
"id": 8, "id": 8,
"name": "rubocop", "name": "rubocop",
"pipeline": { "pipeline": {
......
...@@ -1020,6 +1020,7 @@ module API ...@@ -1020,6 +1020,7 @@ module API
class Job < JobBasic class Job < JobBasic
expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? } expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
expose :runner, with: Runner expose :runner, with: Runner
expose :artifacts_expire_at
end end
class JobBasicWithProject < JobBasic class JobBasicWithProject < JobBasic
......
...@@ -13,7 +13,10 @@ describe API::Jobs do ...@@ -13,7 +13,10 @@ describe API::Jobs do
ref: project.default_branch) ref: project.default_branch)
end 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(:user) { create(:user) }
let(:api_user) { user } let(:api_user) { user }
...@@ -43,6 +46,7 @@ describe API::Jobs do ...@@ -43,6 +46,7 @@ describe API::Jobs do
it 'returns correct values' do it 'returns correct values' do
expect(json_response).not_to be_empty expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id 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 end
it 'returns pipeline data' do it 'returns pipeline data' do
...@@ -128,6 +132,7 @@ describe API::Jobs do ...@@ -128,6 +132,7 @@ describe API::Jobs do
it 'returns correct values' do it 'returns correct values' do
expect(json_response).not_to be_empty expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id 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 end
it 'returns pipeline data' do it 'returns pipeline data' do
...@@ -201,6 +206,7 @@ describe API::Jobs 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['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['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['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) expect(json_response['duration']).to eq(job.duration)
end 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