gitlab-org--gitlab-foss/spec/workers/upload_checksum_worker_spec.rb

35 lines
878 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
describe UploadChecksumWorker do
describe '#perform' do
2018-01-29 12:57:34 -05:00
subject { described_class.new }
context 'without a valid record' do
it 'rescues ActiveRecord::RecordNotFound' do
expect { subject.perform(non_existing_record_id) }.not_to raise_error
2018-01-29 12:57:34 -05:00
end
end
2018-01-29 12:57:34 -05:00
context 'with a valid record' do
let(:upload) { create(:user, :with_avatar).avatar.upload }
before do
expect(Upload).to receive(:find).and_return(upload)
allow(upload).to receive(:foreground_checksumable?).and_return(false)
end
2018-01-29 12:57:34 -05:00
it 'calls calculate_checksum!' do
expect(upload).to receive(:calculate_checksum!)
subject.perform(upload.id)
end
2018-01-29 12:57:34 -05:00
it 'calls save!' do
expect(upload).to receive(:save!)
subject.perform(upload.id)
end
end
end
end