Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d07d9a71b06cb99ee09538ea484363c965df14e5 (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
# 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