debian-mirror-gitlab/spec/presenters/commit_status_presenter_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.7 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe CommitStatusPresenter do
2018-10-15 14:42:47 +05:30
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-11-18 11:00:15 +05:30
2021-11-18 22:05:49 +05:30
describe '#callout_failure_message' do
subject { presenter.callout_failure_message }
context 'when troubleshooting doc is available' do
let(:failure_reason) { :environment_creation_failure }
before do
build.failure_reason = failure_reason
end
it 'appends the troubleshooting link' do
doc = described_class::TROUBLESHOOTING_DOC[failure_reason]
expect(subject).to eq("#{described_class.callout_failure_messages[failure_reason]} " \
"<a href=\"#{presenter.help_page_path(doc[:path], anchor: doc[:anchor])}\">How do I fix it?</a>")
end
end
end
2018-11-18 11:00:15 +05:30
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-10-15 14:42:47 +05:30
end