diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-02 07:28:15 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-02 07:28:15 +0000 |
commit | 8b0b4ecee20e24b52168065ef4c728b370be7ae9 (patch) | |
tree | ad10c0f456fde8f746cd7a4bfbe8d884dd93d071 /spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb | |
parent | b8a848304edc50ec4d4dfbb895dc3c16896c8e10 (diff) | |
parent | 0fd0b64be63c18bb216f15d887e3ce0955dcf269 (diff) | |
download | gitlab-ce-8b0b4ecee20e24b52168065ef4c728b370be7ae9.tar.gz |
Merge branch 'backstage/gb/migrate-pipeline-stages-index' into 'master'
Migrate pipeline stages indices
Closes #43009
See merge request gitlab-org/gitlab-ce!18420
Diffstat (limited to 'spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb new file mode 100644 index 00000000000..f8107dd40b9 --- /dev/null +++ b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 20180420080616 do + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:pipelines) { table(:ci_pipelines) } + let(:stages) { table(:ci_stages) } + let(:jobs) { table(:ci_builds) } + + before do + namespaces.create(id: 10, name: 'gitlab-org', path: 'gitlab-org') + projects.create!(id: 11, namespace_id: 10, name: 'gitlab', path: 'gitlab') + pipelines.create!(id: 12, project_id: 11, ref: 'master', sha: 'adf43c3a') + + stages.create(id: 100, project_id: 11, pipeline_id: 12, name: 'build') + stages.create(id: 101, project_id: 11, pipeline_id: 12, name: 'test') + + jobs.create!(id: 121, commit_id: 12, project_id: 11, + stage_idx: 2, stage_id: 100) + jobs.create!(id: 122, commit_id: 12, project_id: 11, + stage_idx: 2, stage_id: 100) + jobs.create!(id: 123, commit_id: 12, project_id: 11, + stage_idx: 10, stage_id: 100) + jobs.create!(id: 124, commit_id: 12, project_id: 11, + stage_idx: 3, stage_id: 101) + end + + it 'correctly migrates stages indices' do + expect(stages.all.pluck(:position)).to all(be_nil) + + described_class.new.perform(100, 101) + + expect(stages.all.pluck(:position)).to eq [2, 3] + end +end |