Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 18:42:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 18:42:17 +0300
commit44fdf983bd35328dd577d3d3650d14163ef3e2b6 (patch)
tree84ff300d056cfbabb5a0fe2a9cbaa80aaeab1cc5 /spec/lib/gitlab/background_migration
parentbc9fa07b26184b5c94808f704db6ea1ac81bf4de (diff)
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/lib/gitlab/background_migration')
-rw-r--r--spec/lib/gitlab/background_migration/backfill_push_rules_id_in_projects_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/backfill_push_rules_id_in_projects_spec.rb b/spec/lib/gitlab/background_migration/backfill_push_rules_id_in_projects_spec.rb
new file mode 100644
index 00000000000..f150ed4bd2e
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/backfill_push_rules_id_in_projects_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::BackgroundMigration::BackfillPushRulesIdInProjects, :migration, schema: 2020_03_25_162730 do
+ let(:push_rules) { table(:push_rules) }
+ let(:projects) { table(:projects) }
+ let(:project_settings) { table(:project_settings) }
+ let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') }
+
+ subject { described_class.new }
+
+ describe '#perform' do
+ it 'creates new project push_rules for all push rules in the range' do
+ project_1 = projects.create(id: 1, namespace_id: namespace.id)
+ project_2 = projects.create(id: 2, namespace_id: namespace.id)
+ project_3 = projects.create(id: 3, namespace_id: namespace.id)
+ project_settings_1 = project_settings.create(project_id: project_1.id)
+ project_settings_2 = project_settings.create(project_id: project_2.id)
+ project_settings_3 = project_settings.create(project_id: project_3.id)
+ push_rule_1 = push_rules.create(id: 5, is_sample: false, project_id: project_1.id)
+ push_rule_2 = push_rules.create(id: 6, is_sample: false, project_id: project_2.id)
+ push_rules.create(id: 8, is_sample: false, project_id: 3)
+
+ subject.perform(5, 7)
+
+ expect(project_settings_1.reload.push_rule_id).to eq(push_rule_1.id)
+ expect(project_settings_2.reload.push_rule_id).to eq(push_rule_2.id)
+ expect(project_settings_3.reload.push_rule_id).to be_nil
+ end
+ end
+end