2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe BuildArtifactEntity do
|
2020-06-23 00:09:42 +05:30
|
|
|
let(:job) { create(:ci_build) }
|
|
|
|
let(:artifact) { create(:ci_job_artifact, :codequality, expire_at: 1.hour.from_now, job: job) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
let(:entity) do
|
2020-06-23 00:09:42 +05:30
|
|
|
described_class.new(artifact, request: double)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe '#as_json' do
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'contains job name' do
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(subject[:name]).to eq "test:codequality"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'exposes information about expiration of artifacts' do
|
|
|
|
expect(subject).to include(:expired, :expire_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains paths to the artifacts' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(subject[:path])
|
2020-06-23 00:09:42 +05:30
|
|
|
.to include "jobs/#{job.id}/artifacts/download?file_type=codequality"
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
expect(subject[:keep_path])
|
|
|
|
.to include "jobs/#{job.id}/artifacts/keep"
|
|
|
|
|
|
|
|
expect(subject[:browse_path])
|
|
|
|
.to include "jobs/#{job.id}/artifacts/browse"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|