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

waiting_for_approval_status_shared_examples.rb « ci « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44226345fd2230829846a5c3deb35199ed2b688c (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true

RSpec.shared_examples 'a deployment job waiting for approval' do |factory_type|
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:user) { create(:user) }
  let_it_be(:job) { create(factory_type, :manual, environment: 'production', project: project) }

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

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

    let(:job) { create(factory_type, :manual, environment: 'production', project: project) }
    let!(:deployment) { create(:deployment, deployment_status, deployable: job, project: project) }

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

      before do
        allow(deployment).to receive(:waiting_for_approval?).and_return(true)
      end

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

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

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

  describe '#illustration' do
    before do
      environment = create(:environment, name: 'production', project: project)
      create(:deployment, :blocked, project: project, environment: environment, deployable: job)
    end

    it { expect(subject.illustration).to include(:image, :size) }
    it { expect(subject.illustration[:title]).to eq('Waiting for approvals') }

    it do
      expect(subject.illustration[:content]).to include('This job deploys to the protected environment "production"')
    end
  end

  describe '#has_action?' do
    it { expect(subject.has_action?).to be_truthy }
  end

  describe '#action_icon' do
    it { expect(subject.action_icon).to be_nil }
  end

  describe '#action_title' do
    it { expect(subject.action_title).to be_nil }
  end

  describe '#action_button_title' do
    it { expect(subject.action_button_title).to eq('View environment details page') }
  end

  describe '#action_path' do
    before do
      environment = create(:environment, name: 'production', project: project)
      create(:deployment, :blocked, project: project, environment: environment, deployable: job)
    end

    it { expect(subject.action_path).to include('environments') }
  end

  describe '#action_method' do
    it { expect(subject.action_method).to eq(:get) }
  end
end