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
|
2021-04-06 05:09:03 -04:00
|
|
|
let_it_be(:job) { create(:ci_build) }
|
|
|
|
let_it_be(:artifact) { create(:ci_job_artifact, :codequality, expire_at: 1.hour.from_now, job: job) }
|
|
|
|
|
|
|
|
let(:options) { { request: double } }
|
2016-12-21 08:47:20 -05:00
|
|
|
|
|
|
|
let(:entity) do
|
2021-04-06 05:09:03 -04:00
|
|
|
described_class.represent(artifact, options)
|
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
|
|
|
|
|
2021-03-16 17:11:53 -04:00
|
|
|
it 'exposes the artifact download path' do
|
|
|
|
expect(subject[:path]).to include "jobs/#{job.id}/artifacts/download?file_type=codequality"
|
|
|
|
end
|
|
|
|
|
2021-04-06 05:09:03 -04:00
|
|
|
context 'when project is specified in options' do
|
|
|
|
let(:options) { super().merge(project: job.project) }
|
|
|
|
|
|
|
|
it 'doesnt get a project from the artifact' do
|
|
|
|
expect(artifact).not_to receive(:project)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
2016-12-21 08:47:20 -05:00
|
|
|
end
|
|
|
|
end
|