Commit 10499677 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Added Stage tests

parent d47aef58
...@@ -20,6 +20,10 @@ module Ci ...@@ -20,6 +20,10 @@ module Ci
@status ||= statuses.latest.status @status ||= statuses.latest.status
end end
def detailed_status
Gitlab::Ci::Status::Stage::Factory.new(self).fabricate!
end
def statuses def statuses
@statuses ||= pipeline.statuses.where(stage: stage) @statuses ||= pipeline.statuses.where(stage: stage)
end end
......
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
Gitlab::Ci::Status Gitlab::Ci::Status
.const_get(@status.capitalize) .const_get(@status.capitalize)
.new(@stage) .new(@stage)
.extend(Status::Pipeline::Common) .extend(Status::Stage::Common)
end end
def extended_status def extended_status
......
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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment