BigW Consortium Gitlab

ci_status_helper_spec.rb 1.66 KB
Newer Older
1 2 3 4 5
require 'spec_helper'

describe CiStatusHelper do
  include IconsHelper

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

9
  describe '#ci_icon_for_status' do
10
    it 'renders to correct svg on success' do
11 12 13
      expect(helper).to receive(:render)
        .with('shared/icons/icon_status_success.svg', anything)

14 15
      helper.ci_icon_for_status(success_commit.status)
    end
16

17
    it 'renders the correct svg on failure' do
18 19 20
      expect(helper).to receive(:render)
        .with('shared/icons/icon_status_failed.svg', anything)

21 22
      helper.ci_icon_for_status(failed_commit.status)
    end
23
  end
24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  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

48 49
  describe "#pipeline_status_cache_key" do
    it "builds a cache key for pipeline status" do
50
      pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new(
51
        build_stubbed(:project),
52 53 54 55 56 57
        pipeline_info: {
          sha: "123abc",
          status: "success"
        }
      )
      expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success")
58 59
    end
  end
60
end