upload_checksum_worker_spec.rb 533 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
require 'rails_helper'

describe UploadChecksumWorker do
  describe '#perform' do
    it 'rescues ActiveRecord::RecordNotFound' do
      expect { described_class.new.perform(999_999) }.not_to raise_error
    end

    it 'calls calculate_checksum_without_delay and save!' do
      upload = spy
      expect(Upload).to receive(:find).with(999_999).and_return(upload)

      described_class.new.perform(999_999)

      expect(upload).to have_received(:calculate_checksum)
      expect(upload).to have_received(:save!)
    end
  end
end