summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-09-29 00:11:06 +0200
committerMatija Čupić <matteeyah@gmail.com>2018-09-29 00:13:23 +0200
commiteac01d4f658be7b4f5a857c54700a685ada8d1f8 (patch)
tree60f56ae9e40f924bb57d9e5b8183ef4b21f42e97
parentc0716421fac7494bfad058f2608095687be49773 (diff)
downloadgitlab-ce-51651-fill-pipeline-source-for-external-pipelines.tar.gz
Reorganize background_migration specs51651-fill-pipeline-source-for-external-pipelines
This also adds specs for 3 distinct situations: 2. When there is an unknown pipeline with just a build 3. When there is an unknown pipeline with no statuses 1. When there is an unknown pipeline with a build and a status
-rw-r--r--spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb56
1 files changed, 37 insertions, 19 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb b/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
index 05a95cb5ba4..c7b272cd6ca 100644
--- a/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
@@ -6,39 +6,57 @@ describe Gitlab::BackgroundMigration::PopulateExternalPipelineSource, :migration
let(:migration) { described_class.new }
let!(:internal_pipeline) { create(:ci_pipeline, source: :web) }
- let(:pipelines) { [internal_pipeline, external_pipeline, second_external_pipeline].map(&:id) }
+ let(:pipelines) { [internal_pipeline, unknown_pipeline].map(&:id) }
- let!(:external_pipeline) do
- build(:ci_pipeline, source: :unknown)
- .tap { |pipeline| pipeline.save(validate: false) }
- end
- let!(:second_external_pipeline) do
+ let!(:unknown_pipeline) do
build(:ci_pipeline, source: :unknown)
.tap { |pipeline| pipeline.save(validate: false) }
end
- before do
- create(:generic_commit_status, pipeline: external_pipeline)
- create(:ci_build, pipeline: internal_pipeline)
+ subject { migration.perform(pipelines.min, pipelines.max) }
+
+ shared_examples 'no changes' do
+ it 'does not change the pipeline source' do
+ expect { subject }.not_to change { unknown_pipeline.reload.source }
+ end
end
- subject { migration.perform(pipelines.min, pipelines.max) }
+ context 'when unknown pipeline is external' do
+ before do
+ create(:generic_commit_status, pipeline: unknown_pipeline)
+ end
+
+ it 'populates the pipeline source' do
+ subject
+
+ expect(unknown_pipeline.reload.source).to eq('external')
+ end
- it 'populates the pipeline source' do
- subject
+ it 'can be repeated without effect' do
+ subject
- expect(external_pipeline.reload.source).to eq('external')
+ expect { subject }.not_to change { unknown_pipeline.reload.source }
+ end
end
- it 'only processes a single batch of links at a time' do
- subject
+ context 'when unknown pipeline has just a build' do
+ before do
+ create(:ci_build, pipeline: unknown_pipeline)
+ end
+
+ it_behaves_like 'no changes'
+ end
- expect(second_external_pipeline.reload.source).to eq('unknown')
+ context 'when unknown pipeline has no statuses' do
+ it_behaves_like 'no changes'
end
- it 'can be repeated without effect' do
- subject
+ context 'when unknown pipeline has a build and a status' do
+ before do
+ create(:generic_commit_status, pipeline: unknown_pipeline)
+ create(:ci_build, pipeline: unknown_pipeline)
+ end
- expect { subject }.not_to change { external_pipeline.reload.source }
+ it_behaves_like 'no changes'
end
end