debian-mirror-gitlab/spec/serializers/build_artifact_entity_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe BuildArtifactEntity do
2021-04-29 21:17:54 +05:30
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 } }
2017-08-17 22:00:37 +05:30
let(:entity) do
2021-04-29 21:17:54 +05:30
described_class.represent(artifact, options)
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
2021-04-29 21:17:54 +05:30
it 'exposes the artifact download path' do
expect(subject[:path]).to include "jobs/#{job.id}/artifacts/download?file_type=codequality"
end
context 'when project is specified in options' do
let(:options) { super().merge(project: job.project) }
2017-09-10 17:25:29 +05:30
2021-04-29 21:17:54 +05:30
it 'doesnt get a project from the artifact' do
expect(artifact).not_to receive(:project)
2017-09-10 17:25:29 +05:30
2021-04-29 21:17:54 +05:30
subject
end
2017-08-17 22:00:37 +05:30
end
end
end