diff options
Diffstat (limited to 'spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb')
-rw-r--r-- | spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb b/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb new file mode 100644 index 00000000000..d07d9a71b06 --- /dev/null +++ b/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration!('schedule_populate_topics_total_projects_count_cache') + +RSpec.describe SchedulePopulateTopicsTotalProjectsCountCache do + let(:topics) { table(:topics) } + let!(:topic_1) { topics.create!(name: 'Topic1') } + let!(:topic_2) { topics.create!(name: 'Topic2') } + let!(:topic_3) { topics.create!(name: 'Topic3') } + + describe '#up' do + before do + stub_const("#{described_class}::BATCH_SIZE", 2) + end + + it 'schedules BackfillProjectsWithCoverage background jobs', :aggregate_failures do + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, topic_1.id, topic_2.id) + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, topic_3.id, topic_3.id) + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end + end +end |