2017-04-05 15:10:52 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Ci::PipelinePresenter do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-04-05 15:10:52 -04:00
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
|
|
|
|
subject(:presenter) do
|
|
|
|
described_class.new(pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'inherits from Gitlab::View::Presenter::Delegated' do
|
|
|
|
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#initialize' do
|
|
|
|
it 'takes a pipeline and optional params' do
|
|
|
|
expect { presenter }.not_to raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'exposes pipeline' do
|
|
|
|
expect(presenter.pipeline).to eq(pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'forwards missing methods to pipeline' do
|
|
|
|
expect(presenter.ref).to eq(pipeline.ref)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#status_title' do
|
|
|
|
context 'when pipeline is auto-canceled' do
|
|
|
|
before do
|
|
|
|
expect(pipeline).to receive(:auto_canceled?).and_return(true)
|
|
|
|
expect(pipeline).to receive(:auto_canceled_by_id).and_return(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows that the pipeline is auto-canceled' do
|
|
|
|
status_title = presenter.status_title
|
|
|
|
|
|
|
|
expect(status_title).to include('auto-canceled')
|
|
|
|
expect(status_title).to include('Pipeline #1')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline is not auto-canceled' do
|
|
|
|
before do
|
|
|
|
expect(pipeline).to receive(:auto_canceled?).and_return(false)
|
|
|
|
end
|
|
|
|
|
2017-04-06 09:32:56 -04:00
|
|
|
it 'does not have a status title' do
|
2017-04-05 15:10:52 -04:00
|
|
|
expect(presenter.status_title).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-10-03 07:18:59 -04:00
|
|
|
|
|
|
|
context '#failure_reason' do
|
|
|
|
context 'when pipeline has failure reason' do
|
|
|
|
it 'represents a failure reason sentence' do
|
|
|
|
pipeline.failure_reason = :config_error
|
|
|
|
|
|
|
|
expect(presenter.failure_reason)
|
|
|
|
.to eq 'CI/CD YAML configuration error!'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline does not have failure reason' do
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(presenter.failure_reason).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-05 15:10:52 -04:00
|
|
|
end
|