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