2019-10-25 05:06:06 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-16 16:58:20 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe CommitStatusPresenter do
|
2018-05-16 16:58:20 -04:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
let(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
|
|
|
|
subject(:presenter) do
|
|
|
|
described_class.new(build)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'inherits from Gitlab::View::Presenter::Delegated' do
|
|
|
|
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
|
|
|
|
end
|
2018-07-30 11:05:50 -04:00
|
|
|
|
|
|
|
describe 'covers all failure reasons' do
|
|
|
|
let(:message) { presenter.callout_failure_message }
|
|
|
|
|
|
|
|
CommitStatus.failure_reasons.keys.each do |failure_reason|
|
|
|
|
context failure_reason do
|
|
|
|
before do
|
|
|
|
build.failure_reason = failure_reason
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is a valid status" do
|
|
|
|
expect { message }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'invalid failure message' do
|
|
|
|
before do
|
|
|
|
expect(build).to receive(:failure_reason) { 'invalid failure message' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is an invalid status" do
|
|
|
|
expect { message }.to raise_error(/key not found:/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-05-16 16:58:20 -04:00
|
|
|
end
|