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

waiting_for_approval_spec.rb « build « status « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b703a8a47ac020b0fe64c1d57499ebf960cba75b (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 Gitlab::Ci::Status::Build::WaitingForApproval do
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:user) { create(:user) }

  subject { described_class.new(Gitlab::Ci::Status::Core.new(build, user)) }

  describe '#illustration' do
    let(:build) { create(:ci_build, :manual, environment: 'production', project: project) }

    before do
      environment = create(:environment, name: 'production', project: project)
      create(:deployment, :blocked, project: project, environment: environment, deployable: build)
    end

    it { expect(subject.illustration).to include(:image, :size) }
    it { expect(subject.illustration[:title]).to eq('Waiting for approval') }
    it { expect(subject.illustration[:content]).to include('This job deploys to the protected environment "production"') }
  end

  describe '.matches?' do
    subject { described_class.matches?(build, user) }

    let(:build) { create(:ci_build, :manual, environment: 'production', project: project) }

    before do
      create(:deployment, deployment_status, deployable: build, project: project)
    end

    context 'when build is waiting for approval' do
      let(:deployment_status) { :blocked }

      it 'is a correct match' do
        expect(subject).to be_truthy
      end
    end

    context 'when build is not waiting for approval' do
      let(:deployment_status) { :created }

      it 'does not match' do
        expect(subject).to be_falsey
      end
    end
  end
end