bulk_import_worker_spec.rb 717 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe BulkImportWorker do
  4. subject { described_class.new }
  5. let(:import) { Fabricate(:bulk_import, state: :scheduled) }
  6. describe '#perform' do
  7. let(:service_double) { instance_double(BulkImportService, call: nil) }
  8. before do
  9. allow(BulkImportService).to receive(:new).and_return(service_double)
  10. end
  11. it 'changes the import\'s state as appropriate' do
  12. expect { subject.perform(import.id) }.to change { import.reload.state.to_sym }.from(:scheduled).to(:in_progress)
  13. end
  14. it 'calls BulkImportService' do
  15. subject.perform(import.id)
  16. expect(service_double).to have_received(:call).with(import)
  17. end
  18. end
  19. end