require 'test_helper'

class AssetManagerAttachmentMetadataUpdateWorkerTest < ActiveSupport::TestCase
  extend Minitest::Spec::DSL

  let(:subject) { AssetManagerAttachmentMetadataUpdateWorker.new }

  test 'it uses the asset_migration queue' do
    assert_equal 'asset_migration', subject.class.queue
  end

  [
    AssetManagerAttachmentAccessLimitedWorker,
    AssetManagerAttachmentDeleteWorker,
    AssetManagerAttachmentDraftStatusUpdateWorker,
    AssetManagerAttachmentLinkHeaderUpdateWorker,
    AssetManagerAttachmentRedirectUrlUpdateWorker,
    AssetManagerAttachmentReplacementIdUpdateWorker
  ].each do |worker|
    let(:attachment_data) { FactoryBot.create(:attachment_data) }

    test "queues a job on the #{worker}" do
      worker.expects(:perform_async).with(attachment_data.id)
      subject.perform(attachment_data.id)
    end
  end
end

require 'test_helper'

class AssetManagerAttachmentMetadataUpdateWorkerTest < ActiveSupport::TestCase
  extend Minitest::Spec::DSL

  let(:subject) { AssetManagerAttachmentMetadataUpdateWorker.new }
  let(:attachment_data) { FactoryBot.create(:attachment_data) }

  test 'it uses the asset_migration queue' do
    assert_equal 'asset_migration', subject.class.queue
  end

  test 'queues a job on the AssetManagerAttachmentMetadataUpdateWorker' do
    AssetManagerAttachmentAccessLimitedWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end

  test 'queues a job on the AssetManagerAttachmentDeleteWorker' do
    AssetManagerAttachmentDeleteWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end

  test 'queues a job on the AssetManagerAttachmentDraftStatusUpdateWorker' do
    AssetManagerAttachmentDraftStatusUpdateWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end

  test 'queues a job on the AssetManagerAttachmentLinkHeaderUpdateWorker' do
    AssetManagerAttachmentLinkHeaderUpdateWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end

  test 'queues a job on the AssetManagerAttachmentRedirectUrlUpdateWorker' do
    AssetManagerAttachmentRedirectUrlUpdateWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end

  test 'queues a job on the AssetManagerAttachmentReplacementIdUpdateWorker' do
    AssetManagerAttachmentReplacementIdUpdateWorker.expects(:perform_async).with(attachment_data.id)
    subject.perform(attachment_data.id)
  end
end

Split out tests into separate blocks
Split out tests into separate blocks

In a subsequent commit I need to set some expectations on instances
of the individual workers. This change makes it easier and clearer to
do that.
