summaryrefslogtreecommitdiff
path: root/spec/migrations/schedule_fix_incorrect_max_seats_used2_spec.rb
blob: 26764f855b7e2ea4d9b35f168a541ff56c8e78e5 (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
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe ScheduleFixIncorrectMaxSeatsUsed2, :migration, feature_category: :purchase do
  let(:migration_name) { described_class::MIGRATION.to_s.demodulize }

  describe '#up' do
    it 'schedules a job on Gitlab.com' do
      allow(Gitlab).to receive(:com?).and_return(true)

      Sidekiq::Testing.fake! do
        freeze_time do
          migrate!

          expect(migration_name).to be_scheduled_delayed_migration(1.hour, 'batch_2_for_start_date_before_02_aug_2021')
          expect(BackgroundMigrationWorker.jobs.size).to eq(1)
        end
      end
    end

    it 'does not schedule any jobs when not Gitlab.com' do
      allow(Gitlab).to receive(:com?).and_return(false)

      Sidekiq::Testing.fake! do
        migrate!

        expect(migration_name).not_to be_scheduled_delayed_migration
        expect(BackgroundMigrationWorker.jobs.size).to eq(0)
      end
    end
  end
end