summaryrefslogtreecommitdiff
path: root/spec/migrations/schedule_recalculate_project_authorizations_third_run_spec.rb
blob: 302ae1d5ebe917426fae69075db81dd2a060b9c5 (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
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe ScheduleRecalculateProjectAuthorizationsThirdRun do
  let(:users_table) { table(:users) }

  before do
    stub_const("#{described_class}::BATCH_SIZE", 2)

    1.upto(4) do |i|
      users_table.create!(id: i, name: "user#{i}", email: "user#{i}@example.com", projects_limit: 1)
    end
  end

  it 'schedules background migration' do
    Sidekiq::Testing.fake! do
      freeze_time do
        migrate!

        expect(BackgroundMigrationWorker.jobs.size).to eq(2)
        expect(described_class::MIGRATION).to be_scheduled_migration(1, 2)
        expect(described_class::MIGRATION).to be_scheduled_migration(3, 4)
      end
    end
  end
end