diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-06 14:32:24 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-06 14:32:24 +0200 |
commit | b55aad4cc3bf7723f4531635bbb31ab44cae17a9 (patch) | |
tree | 2224c2c5916aadc3e59646de2d864183c97a15eb /spec/migrations | |
parent | 559521ce484d4a95bf3b6ac23bd48c497fdf2703 (diff) | |
download | gitlab-ce-b55aad4cc3bf7723f4531635bbb31ab44cae17a9.tar.gz |
Migrate stages only with correct foreign references
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/migrate_build_stage_reference_spec.rb | 7 | ||||
-rw-r--r-- | spec/migrations/migrate_pipeline_stages_spec.rb | 15 |
2 files changed, 19 insertions, 3 deletions
diff --git a/spec/migrations/migrate_build_stage_reference_spec.rb b/spec/migrations/migrate_build_stage_reference_spec.rb index eaac8f95892..32f9a0c0642 100644 --- a/spec/migrations/migrate_build_stage_reference_spec.rb +++ b/spec/migrations/migrate_build_stage_reference_spec.rb @@ -9,8 +9,15 @@ describe MigrateBuildStageReference, :migration do let(:jobs) { table(:ci_builds) } let(:stages) { table(:ci_stages) } let(:pipelines) { table(:ci_pipelines) } + let(:projects) { table(:projects) } before do + # Create projects + # + projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1') + projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2') + projects.create!(id: 798, name: 'gitlab3', path: 'gitlab3') + # Create CI/CD pipelines # pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') diff --git a/spec/migrations/migrate_pipeline_stages_spec.rb b/spec/migrations/migrate_pipeline_stages_spec.rb index 36d3bd13ac0..c47f2bb8ff9 100644 --- a/spec/migrations/migrate_pipeline_stages_spec.rb +++ b/spec/migrations/migrate_pipeline_stages_spec.rb @@ -9,8 +9,14 @@ describe MigratePipelineStages, :migration do let(:jobs) { table(:ci_builds) } let(:stages) { table(:ci_stages) } let(:pipelines) { table(:ci_pipelines) } + let(:projects) { table(:projects) } before do + # Create projects + # + projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1') + projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2') + # Create CI/CD pipelines # pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') @@ -28,7 +34,8 @@ describe MigratePipelineStages, :migration do jobs.create!(id: 8, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') jobs.create!(id: 9, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1') jobs.create!(id: 10, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2') - jobs.create!(id: 11, commit_id: 3, project_id: 789, stage_idx: 3, stage: 'deploy') + jobs.create!(id: 11, commit_id: 3, project_id: 456, stage_idx: 3, stage: 'deploy') + jobs.create!(id: 12, commit_id: 2, project_id: 789, stage_idx: 3, stage: 'deploy') end it 'correctly migrates pipeline stages' do @@ -36,12 +43,14 @@ describe MigratePipelineStages, :migration do migrate! - expect(stages.count).to eq 7 + expect(stages.count).to eq 6 expect(stages.all.pluck(:name)) - .to match_array %w[test build deploy test:1 test:2 deploy deploy] + .to match_array %w[test build deploy test:1 test:2 deploy] expect(stages.where(pipeline_id: 1).order(:id).pluck(:name)) .to eq %w[test build deploy] expect(stages.where(pipeline_id: 2).order(:id).pluck(:name)) .to eq %w[test:1 test:2 deploy] + expect(stages.where(pipeline_id: 3).count).to be_zero + expect(stages.where(project_id: 789).count).to be_zero end end |