summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb
blob: 90b797965b3fc825715b41168821d8c54ad64aa2 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Ci::Status::Pipeline::Delayed do
  let(:pipeline) { double('pipeline') }

  subject do
    described_class.new(pipeline)
  end

  describe '#text' do
    it 'overrides status text' do
      expect(subject.text).to eq 'delayed'
    end
  end

  describe '#label' do
    it 'overrides status label' do
      expect(subject.label).to eq 'waiting for delayed job'
    end
  end

  describe '.matches?' do
    let(:user) { double('user') }
    subject { described_class.matches?(pipeline, user) }

    context 'when pipeline is scheduled' do
      let(:pipeline) { create(:ci_pipeline, :scheduled) }

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

    context 'when pipeline is not scheduled' do
      let(:pipeline) { create(:ci_pipeline, :success) }

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