summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb')
-rw-r--r--spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb46
1 files changed, 0 insertions, 46 deletions
diff --git a/spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb b/spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb
deleted file mode 100644
index 9194525e713..00000000000
--- a/spec/lib/gitlab/background_migration/backfill_environment_id_deployment_merge_requests_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::BackgroundMigration::BackfillEnvironmentIdDeploymentMergeRequests, schema: 20181228175414 do
- let(:environments) { table(:environments) }
- let(:merge_requests) { table(:merge_requests) }
- let(:deployments) { table(:deployments) }
- let(:deployment_merge_requests) { table(:deployment_merge_requests) }
- let(:namespaces) { table(:namespaces) }
- let(:projects) { table(:projects) }
-
- subject(:migration) { described_class.new }
-
- it 'correctly backfills environment_id column' do
- namespace = namespaces.create!(name: 'foo', path: 'foo')
- project = projects.create!(namespace_id: namespace.id)
-
- production = environments.create!(project_id: project.id, name: 'production', slug: 'production')
- staging = environments.create!(project_id: project.id, name: 'staging', slug: 'staging')
-
- mr = merge_requests.create!(source_branch: 'x', target_branch: 'master', target_project_id: project.id)
-
- deployment1 = deployments.create!(environment_id: staging.id, iid: 1, project_id: project.id, ref: 'master', tag: false, sha: '123abcdef', status: 1)
- deployment2 = deployments.create!(environment_id: production.id, iid: 2, project_id: project.id, ref: 'master', tag: false, sha: '123abcdef', status: 1)
- deployment3 = deployments.create!(environment_id: production.id, iid: 3, project_id: project.id, ref: 'master', tag: false, sha: '123abcdef', status: 1)
-
- # mr is tracked twice in production through deployment2 and deployment3
- deployment_merge_requests.create!(deployment_id: deployment1.id, merge_request_id: mr.id)
- deployment_merge_requests.create!(deployment_id: deployment2.id, merge_request_id: mr.id)
- deployment_merge_requests.create!(deployment_id: deployment3.id, merge_request_id: mr.id)
-
- expect(deployment_merge_requests.where(environment_id: nil).count).to eq(3)
-
- migration.backfill_range(1, mr.id)
-
- expect(deployment_merge_requests.where(environment_id: nil).count).to be_zero
- expect(deployment_merge_requests.count).to eq(2)
-
- production_deployments = deployment_merge_requests.where(environment_id: production.id)
- expect(production_deployments.count).to eq(1)
- expect(production_deployments.first.deployment_id).to eq(deployment2.id)
-
- expect(deployment_merge_requests.where(environment_id: staging.id).count).to eq(1)
- end
-end