debian-mirror-gitlab/spec/helpers/ci_status_helper_spec.rb

61 lines
1.7 KiB
Ruby
Raw Normal View History

2015-10-24 18:46:33 +05:30
require 'spec_helper'
describe CiStatusHelper do
include IconsHelper
let(:success_commit) { double("Ci::Pipeline", status: 'success') }
let(:failed_commit) { double("Ci::Pipeline", status: 'failed') }
2015-10-24 18:46:33 +05:30
2017-08-17 22:00:37 +05:30
describe '#ci_icon_for_status' do
2016-08-24 12:49:21 +05:30
it 'renders to correct svg on success' do
2017-08-17 22:00:37 +05:30
expect(helper).to receive(:render)
.with('shared/icons/icon_status_success.svg', anything)
2016-08-24 12:49:21 +05:30
helper.ci_icon_for_status(success_commit.status)
end
2017-08-17 22:00:37 +05:30
2016-08-24 12:49:21 +05:30
it 'renders the correct svg on failure' do
2017-08-17 22:00:37 +05:30
expect(helper).to receive(:render)
.with('shared/icons/icon_status_failed.svg', anything)
2016-08-24 12:49:21 +05:30
helper.ci_icon_for_status(failed_commit.status)
end
2015-10-24 18:46:33 +05:30
end
2017-08-17 22:00:37 +05:30
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(
2017-09-10 17:25:29 +05:30
build_stubbed(:project),
2017-08-17 22:00:37 +05:30
pipeline_info: {
sha: "123abc",
status: "success"
}
)
expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success")
end
end
2015-10-24 18:46:33 +05:30
end