summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb
new file mode 100644
index 00000000000..8893ed5504b
--- /dev/null
+++ b/spec/support/shared_examples/lib/gitlab/migration_helpers_shared_examples.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'skips validation' do |validation_option|
+ it 'skips validation' do
+ expect(model).not_to receive(:disable_statement_timeout)
+ expect(model).to receive(:execute).with(/ADD CONSTRAINT/)
+ expect(model).not_to receive(:execute).with(/VALIDATE CONSTRAINT/)
+
+ model.add_concurrent_foreign_key(*args, **options.merge(validation_option))
+ end
+end
+
+RSpec.shared_examples 'performs validation' do |validation_option|
+ it 'performs validation' do
+ expect(model).to receive(:disable_statement_timeout).and_call_original
+ expect(model).to receive(:execute).with(/statement_timeout/)
+ expect(model).to receive(:execute).ordered.with(/NOT VALID/)
+ expect(model).to receive(:execute).ordered.with(/VALIDATE CONSTRAINT/)
+ expect(model).to receive(:execute).with(/RESET ALL/)
+
+ model.add_concurrent_foreign_key(*args, **options.merge(validation_option))
+ end
+end