2020-02-10 07:08:59 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'post_migrate', '20200122123016_backfill_project_settings.rb')
|
|
|
|
|
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) }
|
|
|
|
let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') }
|
|
|
|
let(:project) { projects.create(namespace_id: namespace.id) }
|
|
|
|
|
|
|
|
describe '#up' do
|
|
|
|
before do
|
|
|
|
stub_const("#{described_class}::BATCH_SIZE", 2)
|
|
|
|
|
|
|
|
projects.create(id: 1, namespace_id: namespace.id)
|
|
|
|
projects.create(id: 2, namespace_id: namespace.id)
|
|
|
|
projects.create(id: 3, namespace_id: namespace.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'schedules BackfillProjectSettings background jobs' do
|
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
Timecop.freeze do
|
|
|
|
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
|