BigW Consortium Gitlab

build_artifact_entity_spec.rb 810 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe BuildArtifactEntity do
Z.J. van de Weg committed
4
  let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) }
5 6

  let(:entity) do
7
    described_class.new(job, request: double)
8 9 10 11 12
  end

  describe '#as_json' do
    subject { entity.as_json }

13 14
    it 'contains job name' do
      expect(subject[:name]).to eq 'test:job'
15 16
    end

Z.J. van de Weg committed
17 18 19 20 21
    it 'exposes information about expiration of artifacts' do
      expect(subject).to include(:expired, :expire_at)
    end

    it 'contains paths to the artifacts' do
22
      expect(subject[:path])
23
        .to include "jobs/#{job.id}/artifacts/download"
Z.J. van de Weg committed
24 25

      expect(subject[:keep_path])
Z.J. van de Weg committed
26
        .to include "jobs/#{job.id}/artifacts/keep"
Z.J. van de Weg committed
27 28

      expect(subject[:browse_path])
Z.J. van de Weg committed
29
        .to include "jobs/#{job.id}/artifacts/browse"
30 31 32
    end
  end
end