Commit 4731f358 authored by Rémy Coutable's avatar Rémy Coutable

[EE] Reduce diff with CE in spec/models/ci/pipeline_spec.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 699ba7f5
......@@ -10,6 +10,10 @@ describe Ci::Pipeline do
create(:ci_empty_pipeline, status: :created, project: project)
end
it { is_expected.to have_one(:source_pipeline) }
it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_one(:triggered_by_pipeline) }
it { is_expected.to have_many(:triggered_pipelines) }
it { is_expected.to have_many(:job_artifacts).through(:builds) }
it { is_expected.to have_many(:vulnerabilities).through(:vulnerabilities_occurrence_pipelines).class_name('Vulnerabilities::Occurrence') }
it { is_expected.to have_many(:vulnerabilities_occurrence_pipelines).class_name('Vulnerabilities::OccurrencePipeline') }
......@@ -483,4 +487,25 @@ describe Ci::Pipeline do
end
end
end
describe '#ci_yaml_file_path' do
subject { pipeline.ci_yaml_file_path }
context 'the source is the repository' do
let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
before do
pipeline.repository_source!
end
it 'returns the configuration if found' do
allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
.and_return('config')
expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil
end
end
end
end
......@@ -26,10 +26,6 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:auto_canceled_pipelines) }
it { is_expected.to have_many(:auto_canceled_jobs) }
it { is_expected.to have_one(:source_pipeline) }
it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_one(:triggered_by_pipeline) }
it { is_expected.to have_many(:triggered_pipelines) }
it { is_expected.to have_one(:chat_data) }
it { is_expected.to validate_presence_of(:sha) }
......@@ -820,8 +816,7 @@ describe Ci::Pipeline, :mailer do
describe 'pipeline stages' do
describe '#stage_seeds' do
let(:project) { create(:project, :repository) }
let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
let(:pipeline) { build(:ci_pipeline, config: config) }
let(:config) { { rspec: { script: 'rake' } } }
it 'returns preseeded stage seeds object' do
......@@ -851,7 +846,7 @@ describe Ci::Pipeline, :mailer do
context 'when refs policy is specified' do
let(:pipeline) do
build(:ci_pipeline, ref: 'feature', tag: true, project: project, config: config)
build(:ci_pipeline, ref: 'feature', tag: true, config: config)
end
let(:config) do
......@@ -869,9 +864,7 @@ describe Ci::Pipeline, :mailer do
end
context 'when source policy is specified' do
let(:pipeline) do
build(:ci_pipeline, source: :schedule, project: project, config: config)
end
let(:pipeline) { build(:ci_pipeline, source: :schedule, config: config) }
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['triggers'] },
......@@ -911,7 +904,7 @@ describe Ci::Pipeline, :mailer do
end
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project, :repository) }
let(:project) { create(:kubernetes_project) }
let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
......@@ -953,15 +946,13 @@ describe Ci::Pipeline, :mailer do
describe '#seeds_size' do
context 'when refs policy is specified' do
let(:project) { create(:project, :repository) }
let(:config) do
{ production: { stage: 'deploy', script: 'cap prod', only: ['master'] },
spinach: { stage: 'test', script: 'spinach', only: ['tags'] } }
end
let(:pipeline) do
build(:ci_pipeline, ref: 'feature', tag: true, project: project, config: config)
build(:ci_pipeline, ref: 'feature', tag: true, config: config)
end
it 'returns real seeds size' do
......@@ -1945,23 +1936,6 @@ describe Ci::Pipeline, :mailer do
end
end
context 'the source is the repository' do
let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
before do
pipeline.repository_source!
end
it 'returns the configuration if found' do
allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
.and_return('config')
expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil
end
end
context 'when pipeline is for auto-devops' do
before do
pipeline.config_source = 'auto_devops_source'
......@@ -2642,9 +2616,8 @@ describe Ci::Pipeline, :mailer do
end
context 'when pipeline does not have errors' do
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline, project: project, config: { rspec: { script: 'rake test' } })
create(:ci_pipeline, config: { rspec: { script: 'rake test' } })
end
it 'does not contain yaml errors' 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