diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 21:08:39 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-07 21:08:39 +0000 |
commit | 0c6bc5443aa6c8f3e4becccb89fc0f135b4c64c8 (patch) | |
tree | 55f13e752e9061c1800cce510a52fc78b13282ca /spec/migrations/services_remove_temporary_index_on_project_id_spec.rb | |
parent | d7ce7307dca551759ffa972015875f8ebe476927 (diff) | |
download | gitlab-ce-0c6bc5443aa6c8f3e4becccb89fc0f135b4c64c8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/services_remove_temporary_index_on_project_id_spec.rb')
-rw-r--r-- | spec/migrations/services_remove_temporary_index_on_project_id_spec.rb | 40 |
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 |