2015-09-23 06:34:21 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe CiStatusHelper do
|
|
|
|
include IconsHelper
|
|
|
|
|
2016-06-02 10:19:18 -04:00
|
|
|
let(:success_commit) { double("Ci::Pipeline", status: 'success') }
|
|
|
|
let(:failed_commit) { double("Ci::Pipeline", status: 'failed') }
|
2015-09-23 06:34:21 -04:00
|
|
|
|
2017-04-21 16:30:45 -04:00
|
|
|
describe '#ci_icon_for_status' do
|
2016-07-19 14:11:52 -04:00
|
|
|
it 'renders to correct svg on success' do
|
2017-09-29 05:19:51 -04:00
|
|
|
expect(helper.ci_icon_for_status('success').to_s)
|
|
|
|
.to include 'status_success'
|
2016-07-19 14:11:52 -04:00
|
|
|
end
|
2017-04-21 16:30:45 -04:00
|
|
|
|
2016-07-19 14:11:52 -04:00
|
|
|
it 'renders the correct svg on failure' do
|
2017-09-29 06:47:55 -04:00
|
|
|
expect(helper.ci_icon_for_status('failed').to_s)
|
2017-09-29 05:19:51 -04:00
|
|
|
.to include 'status_failed'
|
2016-07-19 14:11:52 -04:00
|
|
|
end
|
2015-09-23 06:34:21 -04:00
|
|
|
end
|
2017-03-16 05:53:48 -04:00
|
|
|
|
2017-04-21 16:30:45 -04:00
|
|
|
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
|
|
|
|
|
2017-03-16 05:53:48 -04:00
|
|
|
describe "#pipeline_status_cache_key" do
|
|
|
|
it "builds a cache key for pipeline status" do
|
2017-04-26 08:04:22 -04:00
|
|
|
pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new(
|
2017-08-02 15:55:11 -04:00
|
|
|
build_stubbed(:project),
|
2017-04-26 08:04:22 -04:00
|
|
|
pipeline_info: {
|
|
|
|
sha: "123abc",
|
|
|
|
status: "success"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success")
|
2017-03-16 05:53:48 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-23 06:34:21 -04:00
|
|
|
end
|