summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/status/build/manual_spec.rb
blob: 150705c1e366b21027d751d03493ea8a3a47652b (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Status::Build::Manual do
  let_it_be(:user) { create(:user) }
  let_it_be(:job) { create(:ci_build, :manual) }

  subject do
    described_class.new(Gitlab::Ci::Status::Core.new(job, user))
  end

  describe '#illustration' do
    it { expect(subject.illustration).to include(:image, :size, :title, :content) }

    context 'when the user can trigger the job' do
      before do
        job.project.add_maintainer(user)
      end

      it { expect(subject.illustration[:content]).to match /This job requires manual intervention to start/ }
    end

    context 'when the user can not trigger the job' do
      it { expect(subject.illustration[:content]).to match /This job does not run automatically and must be started manually/ }
    end
  end

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

    context 'when build is manual' do
      let(:build) { create(:ci_build, :manual) }

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

    context 'when build is not manual' do
      let(:build) { create(:ci_build) }

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