Merge branch 'improve-spec-for-gitlab-ci-status-pipeline-factory' into 'master'

Improve spec for Gitlab::Ci::Status::Pipeline::Factory

Closes #52280

See merge request gitlab-org/gitlab-ce!22247
This commit is contained in:
Grzegorz Bizon 2018-10-15 08:37:47 +00:00
commit a982735718

View file

@ -11,7 +11,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end end
context 'when pipeline has a core status' do context 'when pipeline has a core status' do
HasStatus::AVAILABLE_STATUSES.each do |simple_status| (HasStatus::AVAILABLE_STATUSES - HasStatus::BLOCKED_STATUS).each do |simple_status|
context "when core status is #{simple_status}" do context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) } let(:pipeline) { create(:ci_pipeline, status: simple_status) }
@ -23,24 +23,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(factory.core_status).to be_a expected_status expect(factory.core_status).to be_a expected_status
end end
if simple_status == 'manual' it 'does not match extended statuses' do
it 'matches a correct extended statuses' do expect(factory.extended_statuses).to be_empty
expect(factory.extended_statuses) end
.to eq [Gitlab::Ci::Status::Pipeline::Blocked]
end
elsif simple_status == 'scheduled'
it 'matches a correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Scheduled]
end
else
it 'does not match extended statuses' do
expect(factory.extended_statuses).to be_empty
end
it "fabricates a core status #{simple_status}" do it "fabricates a core status #{simple_status}" do
expect(status).to be_a expected_status expect(status).to be_a expected_status
end
end end
it 'extends core status with common pipeline methods' do it 'extends core status with common pipeline methods' do
@ -51,6 +39,48 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end end
end end
end end
context "when core status is manual" do
let(:pipeline) { create(:ci_pipeline, status: :manual) }
it "matches manual core status" do
expect(factory.core_status)
.to be_a Gitlab::Ci::Status::Manual
end
it 'matches a correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Blocked]
end
it 'extends core status with common pipeline methods' do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
.to include "pipelines/#{pipeline.id}"
end
end
context "when core status is scheduled" do
let(:pipeline) { create(:ci_pipeline, status: :scheduled) }
it "matches scheduled core status" do
expect(factory.core_status)
.to be_a Gitlab::Ci::Status::Scheduled
end
it 'matches a correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Scheduled]
end
it 'extends core status with common pipeline methods' do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
.to include "pipelines/#{pipeline.id}"
end
end
end end
context 'when pipeline has warnings' do context 'when pipeline has warnings' do