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

schedule_merge_request_cleanup_refs_worker_spec.rb « workers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b93202fe9b3eb82db064a39344ffe2192714000b (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
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ScheduleMergeRequestCleanupRefsWorker, feature_category: :code_review_workflow do
  subject(:worker) { described_class.new }

  describe '#perform' do
    it 'does nothing if the database is read-only' do
      allow(Gitlab::Database).to receive(:read_only?).and_return(true)
      expect(MergeRequestCleanupRefsWorker).not_to receive(:perform_with_capacity)

      worker.perform
    end

    context 'when merge_request_refs_cleanup flag is disabled' do
      before do
        stub_feature_flags(merge_request_refs_cleanup: false)
      end

      it 'does not schedule any merge request clean ups' do
        expect(MergeRequestCleanupRefsWorker).not_to receive(:perform_with_capacity)

        worker.perform
      end
    end

    it 'retries stuck cleanup schedules' do
      expect(MergeRequest::CleanupSchedule).to receive(:stuck_retry!)

      worker.perform
    end

    include_examples 'an idempotent worker' do
      it 'schedules MergeRequestCleanupRefsWorker to be performed with capacity' do
        expect(MergeRequestCleanupRefsWorker).to receive(:perform_with_capacity).twice

        subject
      end
    end
  end
end