Added Stage tests
This commit is contained in:
parent
d47aef58cd
commit
10499677e2
|
@ -20,6 +20,10 @@ module Ci
|
|||
@status ||= statuses.latest.status
|
||||
end
|
||||
|
||||
def detailed_status
|
||||
Gitlab::Ci::Status::Stage::Factory.new(self).fabricate!
|
||||
end
|
||||
|
||||
def statuses
|
||||
@statuses ||= pipeline.statuses.where(stage: stage)
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Gitlab
|
|||
Gitlab::Ci::Status
|
||||
.const_get(@status.capitalize)
|
||||
.new(@stage)
|
||||
.extend(Status::Pipeline::Common)
|
||||
.extend(Status::Stage::Common)
|
||||
end
|
||||
|
||||
def extended_status
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Ci::Status::Stage::Common do
|
||||
let(:pipeline) { create(:ci_pipeline) }
|
||||
let(:stage) { Ci::Stage.new(pipeline, 'test') }
|
||||
|
||||
subject do
|
||||
Class.new(Gitlab::Ci::Status::Core)
|
||||
.new(pipeline).extend(described_class)
|
||||
end
|
||||
|
||||
it 'does not have action' do
|
||||
expect(subject).not_to have_action
|
||||
end
|
||||
|
||||
it 'has details' do
|
||||
expect(subject).to have_details
|
||||
end
|
||||
|
||||
it 'links to the pipeline details page' do
|
||||
expect(subject.details_path)
|
||||
.to include "pipelines/#{pipeline.id}"
|
||||
expect(subject.details_path)
|
||||
.to include "##{stage.name}"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Ci::Status::Stage::Factory do
|
||||
let(:pipeline) { create(:ci_pipeline) }
|
||||
let(:stage) { Ci::Stage.new(pipeline, 'test') }
|
||||
|
||||
subject do
|
||||
described_class.new(stage)
|
||||
end
|
||||
|
||||
let(:status) do
|
||||
subject.fabricate!
|
||||
end
|
||||
|
||||
context 'when stage has a core status' do
|
||||
HasStatus::AVAILABLE_STATUSES.each do |core_status|
|
||||
context "when core status is #{core_status}" do
|
||||
let(:build) { create(:ci_build, pipeline: pipeline, stage: stage.name, status: core_status) }
|
||||
|
||||
it "fabricates a core status #{core_status}" do
|
||||
expect(status).to be_a(
|
||||
Gitlab::Ci::Status.const_get(core_status.capitalize))
|
||||
end
|
||||
|
||||
it 'extends core status with common pipeline methods' do
|
||||
expect(status).to have_details
|
||||
expect(status.details_path).to include "pipelines/#{pipeline.id}"
|
||||
expect(status.details_path).to include "##{stage.name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue