Welcome to mirror list, hosted at ThFree Co, Russian Federation.

stage_presenter_spec.rb « ci « presenters « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7187b4ac16c832eab7cdba52700a7a7973f8c0e (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::StagePresenter do
  let(:stage) { create(:ci_stage) }
  let(:presenter) { described_class.new(stage) }

  let!(:build) { create(:ci_build, :tags, :artifacts, pipeline: stage.pipeline, stage: stage.name) }
  let!(:retried_build) { create(:ci_build, :tags, :artifacts, :retried, pipeline: stage.pipeline, stage: stage.name) }

  before do
    create(:generic_commit_status, pipeline: stage.pipeline, ci_stage: stage)
  end

  shared_examples 'preloaded associations for CI status' do
    it 'preloads project' do
      expect(presented_stage.association(:project)).to be_loaded
    end

    it 'preloads build pipeline' do
      expect(presented_stage.association(:pipeline)).to be_loaded
    end

    it 'preloads build tags' do
      expect(presented_stage.association(:tags)).to be_loaded
    end

    it 'preloads build artifacts archive' do
      expect(presented_stage.association(:job_artifacts_archive)).to be_loaded
    end

    it 'preloads build artifacts metadata' do
      expect(presented_stage.association(:metadata)).to be_loaded
    end
  end

  describe '#latest_ordered_statuses' do
    subject(:presented_stage) { presenter.latest_ordered_statuses.second }

    it_behaves_like 'preloaded associations for CI status'
  end

  describe '#retried_ordered_statuses' do
    subject(:presented_stage) { presenter.retried_ordered_statuses.first }

    it_behaves_like 'preloaded associations for CI status'
  end
end