summaryrefslogtreecommitdiff
path: root/spec/serializers/build_artifact_entity_spec.rb
blob: afa2aa3d2548c7c86b2da54330da7bdafe049595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'

describe BuildArtifactEntity do
  let(:job) { create(:ci_build) }
  let(:artifact) { create(:ci_job_artifact, :codequality, expire_at: 1.hour.from_now, job: job) }

  let(:entity) do
    described_class.new(artifact, request: double)
  end

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

    it 'contains job name' do
      expect(subject[:name]).to eq "test:codequality"
    end

    it 'exposes information about expiration of artifacts' do
      expect(subject).to include(:expired, :expire_at)
    end

    it 'contains paths to the artifacts' do
      expect(subject[:path])
        .to include "jobs/#{job.id}/artifacts/download?file_type=codequality"

      expect(subject[:keep_path])
        .to include "jobs/#{job.id}/artifacts/keep"

      expect(subject[:browse_path])
        .to include "jobs/#{job.id}/artifacts/browse"
    end
  end
end