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

scheduled_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: f98183d6d1871e4b3166b51c0a3dd9e4b618dff1 (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
require 'spec_helper'

describe Gitlab::Ci::Status::Build::Scheduled do
  let(:user) { create(:user) }
  let(:project) { create(:project, :stubbed_repository) }
  let(:build) { create(:ci_build, :scheduled, project: project) }
  let(:status) { Gitlab::Ci::Status::Core.new(build, user) }

  subject { described_class.new(status) }

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

  describe '#status_tooltip' do
    context 'when scheduled_at is not expired' do
      let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }

      it 'shows execute_in of the scheduled job' do
        Timecop.freeze(Time.now.change(usec: 0)) do
          expect(subject.status_tooltip).to include('00:01:00')
        end
      end
    end

    context 'when scheduled_at is expired' do
      let(:build) { create(:ci_build, :expired_scheduled, project: project) }

      it 'shows 00:00:00' do
        Timecop.freeze do
          expect(subject.status_tooltip).to include('00:00:00')
        end
      end
    end
  end

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

    context 'when build is scheduled and scheduled_at is present' do
      let(:build) { create(:ci_build, :expired_scheduled, project: project) }

      it { is_expected.to be_truthy }
    end

    context 'when build is scheduled' do
      let(:build) { create(:ci_build, status: :scheduled, project: project) }

      it { is_expected.to be_falsy }
    end

    context 'when scheduled_at is present' do
      let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }

      it { is_expected.to be_falsy }
    end
  end
end