2020-02-10 07:08:59 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2021-06-11 14:10:13 -04:00
|
|
|
require_migration!('backfill_project_settings')
|
2020-02-10 07:08:59 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe BackfillProjectSettings, :sidekiq, schema: 20200114113341 do
|
2020-02-10 07:08:59 -05:00
|
|
|
let(:projects) { table(:projects) }
|
2020-12-10 16:10:15 -05:00
|
|
|
let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
|
|
|
|
let(:project) { projects.create!(namespace_id: namespace.id) }
|
2020-02-10 07:08:59 -05:00
|
|
|
|
|
|
|
describe '#up' do
|
|
|
|
before do
|
|
|
|
stub_const("#{described_class}::BATCH_SIZE", 2)
|
|
|
|
|
2020-12-10 16:10:15 -05:00
|
|
|
projects.create!(id: 1, namespace_id: namespace.id)
|
|
|
|
projects.create!(id: 2, namespace_id: namespace.id)
|
|
|
|
projects.create!(id: 3, namespace_id: namespace.id)
|
2020-02-10 07:08:59 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'schedules BackfillProjectSettings background jobs' do
|
|
|
|
Sidekiq::Testing.fake! do
|
2020-08-31 11:10:41 -04:00
|
|
|
freeze_time do
|
2020-02-10 07:08:59 -05:00
|
|
|
migrate!
|
|
|
|
|
|
|
|
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2)
|
|
|
|
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 3, 3)
|
|
|
|
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|