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:
Diffstat (limited to 'spec/lib/gitlab/background_migration/cleanup_concurrent_schema_change_spec.rb')
-rw-r--r--spec/lib/gitlab/background_migration/cleanup_concurrent_schema_change_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/cleanup_concurrent_schema_change_spec.rb b/spec/lib/gitlab/background_migration/cleanup_concurrent_schema_change_spec.rb
new file mode 100644
index 00000000000..2931b5e6dd3
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/cleanup_concurrent_schema_change_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+RSpec.describe Gitlab::BackgroundMigration::CleanupConcurrentSchemaChange do
+ describe '#perform' do
+ it 'new column does not exist' do
+ expect(subject).to receive(:column_exists?).with(:issues, :closed_at_timestamp).and_return(false)
+ expect(subject).not_to receive(:column_exists?).with(:issues, :closed_at)
+ expect(subject).not_to receive(:define_model_for)
+
+ expect(subject.perform(:issues, :closed_at, :closed_at_timestamp)).to be_nil
+ end
+
+ it 'old column does not exist' do
+ expect(subject).to receive(:column_exists?).with(:issues, :closed_at_timestamp).and_return(true)
+ expect(subject).to receive(:column_exists?).with(:issues, :closed_at).and_return(false)
+ expect(subject).not_to receive(:define_model_for)
+
+ expect(subject.perform(:issues, :closed_at, :closed_at_timestamp)).to be_nil
+ end
+
+ it 'has both old and new columns' do
+ expect(subject).to receive(:column_exists?).twice.and_return(true)
+
+ expect { subject.perform('issues', :closed_at, :created_at) }.to raise_error(NotImplementedError)
+ end
+ end
+end