Commit 3ed77673 authored by James Lopez's avatar James Lopez

Merge branch 'refactor-ci-processable-delegation-specs' into 'master'

Refactor CI processable delegation specs

See merge request gitlab-org/gitlab!29605
parents b244f028 eab5215b
......@@ -3,40 +3,9 @@
require 'spec_helper'
describe Ci::Processable do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
describe 'delegations' do
subject { Ci::Processable.new }
let_it_be(:detached_merge_request_pipeline) do
create(:ci_pipeline, :detached_merge_request_pipeline, :with_job, project: project)
end
let_it_be(:legacy_detached_merge_request_pipeline) do
create(:ci_pipeline, :legacy_detached_merge_request_pipeline, :with_job, project: project)
end
let_it_be(:merged_result_pipeline) do
create(:ci_pipeline, :merged_result_pipeline, :with_job, project: project)
end
describe '#merge_train_pipeline?' do
subject { pipeline.processables.first.merge_train_pipeline? }
context 'in a detached merge request pipeline' do
let(:pipeline) { detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_train_pipeline?) }
end
context 'in a legacy detached merge_request_pipeline' do
let(:pipeline) { legacy_detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_train_pipeline?) }
end
context 'in a pipeline for merged results' do
let(:pipeline) { merged_result_pipeline }
it { is_expected.to eq(pipeline.merge_train_pipeline?) }
end
it { is_expected.to delegate_method(:merge_train_pipeline?).to(:pipeline) }
end
end
......@@ -6,16 +6,12 @@ describe Ci::Processable do
let_it_be(:project) { create(:project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let_it_be(:detached_merge_request_pipeline) do
create(:ci_pipeline, :detached_merge_request_pipeline, :with_job, project: project)
end
let_it_be(:legacy_detached_merge_request_pipeline) do
create(:ci_pipeline, :legacy_detached_merge_request_pipeline, :with_job, project: project)
end
describe 'delegations' do
subject { Ci::Processable.new }
let_it_be(:merged_result_pipeline) do
create(:ci_pipeline, :merged_result_pipeline, :with_job, project: project)
it { is_expected.to delegate_method(:merge_request?).to(:pipeline) }
it { is_expected.to delegate_method(:merge_request_ref?).to(:pipeline) }
it { is_expected.to delegate_method(:legacy_detached_merge_request_pipeline?).to(:pipeline) }
end
describe '#aggregated_needs_names' do
......@@ -132,70 +128,4 @@ describe Ci::Processable do
it { is_expected.to be_empty }
end
end
describe '#merge_request?' do
subject { pipeline.processables.first.merge_request? }
context 'in a detached merge request pipeline' do
let(:pipeline) { detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_request?) }
end
context 'in a legacy detached merge_request_pipeline' do
let(:pipeline) { legacy_detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_request?) }
end
context 'in a pipeline for merged results' do
let(:pipeline) { merged_result_pipeline }
it { is_expected.to eq(pipeline.merge_request?) }
end
end
describe '#merge_request_ref?' do
subject { pipeline.processables.first.merge_request_ref? }
context 'in a detached merge request pipeline' do
let(:pipeline) { detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_request_ref?) }
end
context 'in a legacy detached merge_request_pipeline' do
let(:pipeline) { legacy_detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.merge_request_ref?) }
end
context 'in a pipeline for merged results' do
let(:pipeline) { merged_result_pipeline }
it { is_expected.to eq(pipeline.merge_request_ref?) }
end
end
describe '#legacy_detached_merge_request_pipeline?' do
subject { pipeline.processables.first.legacy_detached_merge_request_pipeline? }
context 'in a detached merge request pipeline' do
let(:pipeline) { detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.legacy_detached_merge_request_pipeline?) }
end
context 'in a legacy detached merge_request_pipeline' do
let(:pipeline) { legacy_detached_merge_request_pipeline }
it { is_expected.to eq(pipeline.legacy_detached_merge_request_pipeline?) }
end
context 'in a pipeline for merged results' do
let(:pipeline) { merged_result_pipeline }
it { is_expected.to eq(pipeline.legacy_detached_merge_request_pipeline?) }
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