2023-11-16 15:36:59 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe ImportWorker do
|
2023-11-16 15:36:59 +01:00
|
|
|
let(:worker) { described_class.new }
|
|
|
|
let(:service) { instance_double(ImportService, call: true) }
|
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
before do
|
|
|
|
allow(ImportService).to receive(:new).and_return(service)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:import) { Fabricate(:import) }
|
|
|
|
|
|
|
|
it 'sends the import to the service' do
|
|
|
|
worker.perform(import.id)
|
|
|
|
|
|
|
|
expect(service).to have_received(:call).with(import)
|
|
|
|
expect { import.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|