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
|
2021-04-06 09:09:03 +00: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 13:47:20 +00:00
|
|
|
|
|
|
|
let(:entity) do
|
2021-04-06 09:09:03 +00:00
|
|
|
described_class.represent(artifact, options)
|
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
|
|
|
|
|
2021-03-16 21:11:53 +00: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 09:09:03 +00: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 13:47:20 +00:00
|
|
|
end
|
|
|
|
end
|