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

ci_status_helper_spec.rb « helpers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc2422aba908eb487d179a6997a808ef260aa7ee (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
require 'spec_helper'

describe CiStatusHelper do
  include IconsHelper

  let(:success_commit) { double("Ci::Pipeline", status: 'success') }
  let(:failed_commit) { double("Ci::Pipeline", status: 'failed') }

  describe '#ci_icon_for_status' do
    it 'renders to correct svg on success' do
      expect(helper.ci_icon_for_status('success').to_s)
        .to include 'status_success'
    end

    it 'renders the correct svg on failure' do
      expect(helper.ci_icon_for_status('failed').to_s)
        .to include 'status_failed'
    end
  end

  describe '#ci_text_for_status' do
    context 'when status is manual' do
      it 'changes the status to blocked' do
        expect(helper.ci_text_for_status('manual'))
          .to eq 'blocked'
      end
    end

    context 'when status is success' do
      it 'changes the status to passed' do
        expect(helper.ci_text_for_status('success'))
          .to eq 'passed'
      end
    end

    context 'when status is something else' do
      it 'returns status unchanged' do
        expect(helper.ci_text_for_status('some-status'))
          .to eq 'some-status'
      end
    end
  end

  describe "#pipeline_status_cache_key" do
    it "builds a cache key for pipeline status" do
      pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new(
        build_stubbed(:project),
        pipeline_info: {
          sha: "123abc",
          status: "success"
        }
      )
      expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success")
    end
  end
end