Commit ee18d89f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extend pipeline detailed status factory specs

parent 528c0688
...@@ -3,29 +3,32 @@ require 'spec_helper' ...@@ -3,29 +3,32 @@ require 'spec_helper'
describe Gitlab::Ci::Status::Pipeline::Factory do describe Gitlab::Ci::Status::Pipeline::Factory do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { pipeline.project } let(:project) { pipeline.project }
let(:status) { factory.fabricate! }
let(:factory) { described_class.new(pipeline, user) }
subject do before do
described_class.new(pipeline, user) project.team << [user, :developer]
end end
let(:status) do context 'when pipeline has a core status' do
subject.fabricate! HasStatus::AVAILABLE_STATUSES.each do |simple_status|
context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) }
let(:expected_status) do
Gitlab::Ci::Status.const_get(simple_status.capitalize)
end end
before do it "matches correct core status for #{simple_status}" do
project.team << [user, :developer] expect(factory.core_status).to be_a expected_status
end end
context 'when pipeline has a core status' do it 'does not matche extended statuses' do
HasStatus::AVAILABLE_STATUSES.each do |core_status| expect(factory.extended_statuses).to be_empty
context "when core status is #{core_status}" do
let(:pipeline) do
create(:ci_pipeline, status: core_status)
end end
it "fabricates a core status #{core_status}" do it "fabricates a core status #{simple_status}" do
expect(status).to be_a( expect(status).to be_a expected_status
Gitlab::Ci::Status.const_get(core_status.capitalize))
end end
it 'extends core status with common pipeline methods' do it 'extends core status with common pipeline methods' do
...@@ -47,9 +50,17 @@ describe Gitlab::Ci::Status::Pipeline::Factory do ...@@ -47,9 +50,17 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline) create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline)
end end
it 'matches correct core status' do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
it 'matches correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::SuccessWarning]
end
it 'fabricates extended "success with warnings" status' do it 'fabricates extended "success with warnings" status' do
expect(status) expect(status).to be_a Gitlab::Ci::Status::SuccessWarning
.to be_a Gitlab::Ci::Status::SuccessWarning
end end
it 'extends core status with common pipeline method' do it 'extends core status with common pipeline method' do
......
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