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-02-08 00:08:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-08 00:08:39 +0300
commit0c6bc5443aa6c8f3e4becccb89fc0f135b4c64c8 (patch)
tree55f13e752e9061c1800cce510a52fc78b13282ca /spec/migrations
parentd7ce7307dca551759ffa972015875f8ebe476927 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/services_remove_temporary_index_on_project_id_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/migrations/services_remove_temporary_index_on_project_id_spec.rb b/spec/migrations/services_remove_temporary_index_on_project_id_spec.rb
new file mode 100644
index 00000000000..f730d7aecfd
--- /dev/null
+++ b/spec/migrations/services_remove_temporary_index_on_project_id_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200203104214_services_remove_temporary_index_on_project_id.rb')
+
+describe ServicesRemoveTemporaryIndexOnProjectId, :migration do
+ let(:migration_instance) { described_class.new }
+
+ it 'adds and removes temporary partial index in up and down methods' do
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(migration_instance.index_exists?(:services, :project_id, name: described_class::INDEX_NAME)).to be true
+ }
+
+ migration.after -> {
+ expect(migration_instance.index_exists?(:services, :project_id, name: described_class::INDEX_NAME)).to be false
+ }
+ end
+ end
+
+ describe '#up' do
+ context 'index does not exist' do
+ it 'skips removal action' do
+ migrate!
+
+ expect { migrate! }.not_to change { migration_instance.index_exists?(:services, :project_id, name: described_class::INDEX_NAME) }
+ end
+ end
+ end
+
+ describe '#down' do
+ context 'index already exists' do
+ it 'skips creation of duplicated temporary partial index on project_id' do
+ schema_migrate_down!
+
+ expect { schema_migrate_down! }.not_to change { migration_instance.index_exists?(:services, :project_id, name: described_class::INDEX_NAME) }
+ end
+ end
+ end
+end