summaryrefslogtreecommitdiff
path: root/spec/migrations/20230508175057_backfill_corrected_secure_files_expirations_spec.rb
blob: 570be0e02c748c7da5abe975267f78c4b391a0d5 (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
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe BackfillCorrectedSecureFilesExpirations, migration: :gitlab_ci, feature_category: :mobile_devops do
  let(:migration) { described_class.new }
  let(:ci_secure_files) { table(:ci_secure_files) }

  let!(:file1) { ci_secure_files.create!(project_id: 1, name: "file.cer", file: "foo", checksum: 'bar') }
  let!(:file2) { ci_secure_files.create!(project_id: 1, name: "file.p12", file: "foo", checksum: 'bar') }
  let!(:file3) { ci_secure_files.create!(project_id: 1, name: "file.jks", file: "foo", checksum: 'bar') }

  describe '#up' do
    it 'enqueues the ParseSecureFileMetadataWorker job for relevant file types', :aggregate_failures do
      expect(::Ci::ParseSecureFileMetadataWorker).to receive(:perform_async).with(file1.id)
      expect(::Ci::ParseSecureFileMetadataWorker).to receive(:perform_async).with(file2.id)
      expect(::Ci::ParseSecureFileMetadataWorker).not_to receive(:perform_async).with(file3.id)

      migration.up
    end
  end
end