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-01-28 21:08:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 21:08:35 +0300
commit6315ed9630fb1c6ade3114beb762cd1568d79219 (patch)
tree2a5d31936d09c14420c8f4c8bd752e268f0eb19f /spec/migrations
parentfedf978f9aa1909ed7bb3fad767ad120a1c6bd7b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/backfill_operations_feature_flags_iid_spec.rb34
-rw-r--r--spec/migrations/delete_internal_ids_where_feature_flags_usage_spec.rb44
2 files changed, 78 insertions, 0 deletions
diff --git a/spec/migrations/backfill_operations_feature_flags_iid_spec.rb b/spec/migrations/backfill_operations_feature_flags_iid_spec.rb
new file mode 100644
index 00000000000..f7a223e794a
--- /dev/null
+++ b/spec/migrations/backfill_operations_feature_flags_iid_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200117194850_backfill_operations_feature_flags_iid.rb')
+
+describe BackfillOperationsFeatureFlagsIid, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:flags) { table(:operations_feature_flags) }
+
+ def setup
+ namespace = namespaces.create!(name: 'foo', path: 'foo')
+ project = projects.create!(namespace_id: namespace.id)
+
+ project
+ end
+
+ it 'migrates successfully when there are no flags in the database' do
+ setup
+
+ disable_migrations_output { migrate! }
+
+ expect(flags.count).to eq(0)
+ end
+
+ it 'migrates successfully with a row in the table in both FOSS and EE' do
+ project = setup
+ flags.create!(project_id: project.id, active: true, name: 'test_flag')
+
+ disable_migrations_output { migrate! }
+
+ expect(flags.count).to eq(1)
+ end
+end
diff --git a/spec/migrations/delete_internal_ids_where_feature_flags_usage_spec.rb b/spec/migrations/delete_internal_ids_where_feature_flags_usage_spec.rb
new file mode 100644
index 00000000000..b9c6b489aca
--- /dev/null
+++ b/spec/migrations/delete_internal_ids_where_feature_flags_usage_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200117194900_delete_internal_ids_where_feature_flags_usage')
+
+describe DeleteInternalIdsWhereFeatureFlagsUsage, :migration do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:internal_ids) { table(:internal_ids) }
+
+ def setup
+ namespace = namespaces.create!(name: 'foo', path: 'foo')
+ project = projects.create!(namespace_id: namespace.id)
+
+ project
+ end
+
+ it 'deletes feature flag rows from the internal_ids table' do
+ project = setup
+ internal_ids.create!(project_id: project.id, usage: 6, last_value: 1)
+
+ disable_migrations_output { migrate! }
+
+ expect(internal_ids.count).to eq(0)
+ end
+
+ it 'does not delete issue rows from the internal_ids table' do
+ project = setup
+ internal_ids.create!(project_id: project.id, usage: 0, last_value: 1)
+
+ disable_migrations_output { migrate! }
+
+ expect(internal_ids.count).to eq(1)
+ end
+
+ it 'does not delete merge request rows from the internal_ids table' do
+ project = setup
+ internal_ids.create!(project_id: project.id, usage: 1, last_value: 1)
+
+ disable_migrations_output { migrate! }
+
+ expect(internal_ids.count).to eq(1)
+ end
+end