summaryrefslogtreecommitdiff
path: root/spec/migrations/ensure_vum_bigint_backfill_is_finished_for_gl_dot_com_spec.rb
blob: d582a8a94606b1de8d9a23f61250b700d17b3e41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe EnsureVumBigintBackfillIsFinishedForGlDotCom, feature_category: :database do
  describe '#up' do
    let(:migration_arguments) do
      {
        job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
        table_name: 'vulnerability_user_mentions',
        column_name: 'id',
        job_arguments: [['note_id'], ['note_id_convert_to_bigint']]
      }
    end

    it 'ensures the migration is completed for GitLab.com, dev, or test' do
      expect_next_instance_of(described_class) do |instance|
        expect(instance).to receive(:com_or_dev_or_test_but_not_jh?).and_return(true)
        expect(instance).to receive(:ensure_batched_background_migration_is_finished).with(migration_arguments)
      end

      migrate!
    end

    it 'skips the check for other instances' do
      expect_next_instance_of(described_class) do |instance|
        expect(instance).to receive(:com_or_dev_or_test_but_not_jh?).and_return(false)
        expect(instance).not_to receive(:ensure_batched_background_migration_is_finished)
      end

      migrate!
    end
  end
end