summaryrefslogtreecommitdiff
path: root/spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 01:22:57 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 01:22:57 +0000
commit7fa016711e540f9b6dda45aa1f47867737c52940 (patch)
tree545fa4ba39a17df75301c6c90d7aef1e77cba98d /spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb
parentee3c8d00bd8c17201da0b116a9b3b276804b855f (diff)
downloadgitlab-ce-7fa016711e540f9b6dda45aa1f47867737c52940.tar.gz
Add latest changes from gitlab-org/gitlab@15-11-stable-ee
Diffstat (limited to 'spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb')
-rw-r--r--spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb b/spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb
new file mode 100644
index 00000000000..3f3fdd0889d
--- /dev/null
+++ b/spec/migrations/20220128155814_fix_approval_rules_code_owners_rule_type_index_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!('fix_approval_rules_code_owners_rule_type_index')
+
+RSpec.describe FixApprovalRulesCodeOwnersRuleTypeIndex, :migration, feature_category: :source_code_management do
+ let(:table_name) { :approval_merge_request_rules }
+ let(:index_name) { 'index_approval_rules_code_owners_rule_type' }
+
+ it 'correctly migrates up and down' do
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(subject.index_exists_by_name?(table_name, index_name)).to be_truthy
+ }
+
+ migration.after -> {
+ expect(subject.index_exists_by_name?(table_name, index_name)).to be_truthy
+ }
+ end
+ end
+
+ context 'when the index already exists' do
+ before do
+ subject.add_concurrent_index table_name, :merge_request_id, where: 'rule_type = 2', name: index_name
+ end
+
+ it 'keeps the index' do
+ migrate!
+
+ expect(subject.index_exists_by_name?(table_name, index_name)).to be_truthy
+ end
+ end
+end