summaryrefslogtreecommitdiff
path: root/spec/migrations/migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue_spec.rb
blob: 15c5761bd99badec46e4bec43e6650cb1f88f9f8 (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
# frozen_string_literal: true

require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200213220211_migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue.rb')

RSpec.describe MigrateSyncSecurityReportsToReportApprovalRulesSidekiqQueue, :redis do
  include Gitlab::Database::MigrationHelpers
  include StubWorker

  context 'when there are jobs in the queue' do
    it 'migrates queue when migrating up' do
      Sidekiq::Testing.disable! do
        stub_worker(queue: 'pipeline_default:sync_security_reports_to_report_approval_rules').perform_async(1, 5)

        described_class.new.up

        expect(sidekiq_queue_length('pipeline_default:sync_security_reports_to_report_approval_rules')).to eq 0
        expect(sidekiq_queue_length('security_scans:sync_security_reports_to_report_approval_rules')).to eq 1
      end
    end

    it 'migrates queue when migrating down' do
      Sidekiq::Testing.disable! do
        stub_worker(queue: 'security_scans:sync_security_reports_to_report_approval_rules').perform_async(1, 5)

        described_class.new.down

        expect(sidekiq_queue_length('pipeline_default:sync_security_reports_to_report_approval_rules')).to eq 1
        expect(sidekiq_queue_length('security_scans:sync_security_reports_to_report_approval_rules')).to eq 0
      end
    end
  end
end