2019-09-30 05:06:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-21 08:47:20 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe BuildArtifactEntity do
|
2020-06-04 08:08:21 -04:00
|
|
|
let(:job) { create(:ci_build) }
|
|
|
|
let(:artifact) { create(:ci_job_artifact, :codequality, expire_at: 1.hour.from_now, job: job) }
|
2016-12-21 08:47:20 -05:00
|
|
|
|
|
|
|
let(:entity) do
|
2020-06-04 08:08:21 -04:00
|
|
|
described_class.new(artifact, request: double)
|
2016-12-21 08:47:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#as_json' do
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
2017-05-16 07:41:15 -04:00
|
|
|
it 'contains job name' do
|
2020-06-04 08:08:21 -04:00
|
|
|
expect(subject[:name]).to eq "test:codequality"
|
2016-12-21 08:47:20 -05:00
|
|
|
end
|
|
|
|
|
2017-05-29 03:58:20 -04:00
|
|
|
it 'exposes information about expiration of artifacts' do
|
|
|
|
expect(subject).to include(:expired, :expire_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains paths to the artifacts' do
|
2016-12-21 08:47:20 -05:00
|
|
|
expect(subject[:path])
|
2020-06-04 08:08:21 -04:00
|
|
|
.to include "jobs/#{job.id}/artifacts/download?file_type=codequality"
|
2017-05-29 03:58:20 -04:00
|
|
|
|
|
|
|
expect(subject[:keep_path])
|
2017-05-31 16:10:00 -04:00
|
|
|
.to include "jobs/#{job.id}/artifacts/keep"
|
2017-05-29 03:58:20 -04:00
|
|
|
|
|
|
|
expect(subject[:browse_path])
|
2017-05-31 16:10:00 -04:00
|
|
|
.to include "jobs/#{job.id}/artifacts/browse"
|
2016-12-21 08:47:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|