summaryrefslogtreecommitdiff
path: root/spec/workers/issues/reschedule_stuck_issue_rebalances_worker_spec.rb
blob: 02d1241d2ba7c161fe9373a64d89c83dc48a3abc (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Issues::RescheduleStuckIssueRebalancesWorker, :clean_gitlab_redis_shared_state do
  let_it_be(:group) { create(:group) }
  let_it_be(:project) { create(:project, group: group) }

  subject(:worker) { described_class.new }

  describe '#perform' do
    it 'does not schedule a rebalance' do
      expect(IssueRebalancingWorker).not_to receive(:perform_async)

      worker.perform
    end

    it 'schedules a rebalance in case there are any rebalances started' do
      expect(::Gitlab::Issues::Rebalancing::State).to receive(:fetch_rebalancing_groups_and_projects).and_return([[group.id], [project.id]])
      expect(IssueRebalancingWorker).to receive(:bulk_perform_async).with([[nil, nil, group.id]]).once
      expect(IssueRebalancingWorker).to receive(:bulk_perform_async).with([[nil, project.id, nil]]).once

      worker.perform
    end
  end
end