summaryrefslogtreecommitdiff
path: root/spec/migrations/clean_stage_id_reference_migration_spec.rb
blob: 1b8d044ed61a04e56dde7d9e2657a38f2b8f774c (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
require 'spec_helper'
require Rails.root.join('db', 'migrate', '20170710083355_clean_stage_id_reference_migration.rb')
require Rails.root.join('db', 'post_migrate', '20170628080858_migrate_stage_id_reference_in_background')

describe CleanStageIdReferenceMigration, :migration, :sidekiq, :redis do
  let(:migration) { MigrateStageIdReferenceInBackground::MIGRATION }

  context 'when there are pending background migrations' do
    it 'processes pending jobs synchronously' do
      Sidekiq::Testing.disable! do
        BackgroundMigrationWorker.perform_in(2.minutes, migration, [1])
        BackgroundMigrationWorker.perform_async(migration, [1])

        expect(Gitlab::BackgroundMigration).to receive(:perform).twice

        migrate!
      end
    end
  end

  context 'when there are no background migrations pending' do
    it 'does nothing' do
      Sidekiq::Testing.disable! do
        expect(Gitlab::BackgroundMigration).not_to receive(:perform)

        migrate!
      end
    end
  end
end