summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/status/stage/play_manual_spec.rb
blob: b0113b00ef06648b783accda4a30e44aae02d1a4 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Ci::Status::Stage::PlayManual do
  let(:stage) { double('stage') }
  let(:play_manual) { described_class.new(stage) }

  describe '#action_icon' do
    subject { play_manual.action_icon }

    it { is_expected.to eq('play') }
  end

  describe '#action_button_title' do
    subject { play_manual.action_button_title }

    it { is_expected.to eq('Play all manual') }
  end

  describe '#action_title' do
    subject { play_manual.action_title }

    it { is_expected.to eq('Play all manual') }
  end

  describe '#action_path' do
    let(:stage) { create(:ci_stage_entity, status: 'manual') }
    let(:pipeline) { stage.pipeline }
    let(:play_manual) { stage.detailed_status(create(:user)) }

    subject { play_manual.action_path }

    it { is_expected.to eq("/#{pipeline.project.full_path}/pipelines/#{pipeline.id}/stages/#{stage.name}/play_manual") }
  end

  describe '#action_method' do
    subject { play_manual.action_method }

    it { is_expected.to eq(:post) }
  end

  describe '.matches?' do
    let(:user) { double('user') }

    subject { described_class.matches?(stage, user) }

    context 'when stage is skipped' do
      let(:stage) { create(:ci_stage_entity, status: :skipped) }

      it { is_expected.to be_truthy }
    end

    context 'when stage is manual' do
      let(:stage) { create(:ci_stage_entity, status: :manual) }

      it { is_expected.to be_truthy }
    end

    context 'when stage is scheduled' do
      let(:stage) { create(:ci_stage_entity, status: :scheduled) }

      it { is_expected.to be_truthy }
    end

    context 'when stage is success' do
      let(:stage) { create(:ci_stage_entity, status: :success) }

      context 'and does not have manual builds' do
        it { is_expected.to be_falsy }
      end
    end
  end
end