~cytrogen/masto-fe

ref: b2d67fbe339d4852c97cd332a92a2c32b8835cdb masto-fe/spec/workers/bulk_import_worker_spec.rb -rw-r--r-- 717 bytes
b2d67fbe — Renaud Chaput [Glitch] Improve modals reducer types 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require 'rails_helper'

describe BulkImportWorker do
  subject { described_class.new }

  let(:import) { Fabricate(:bulk_import, state: :scheduled) }

  describe '#perform' do
    let(:service_double) { instance_double(BulkImportService, call: nil) }

    before do
      allow(BulkImportService).to receive(:new).and_return(service_double)
    end

    it 'changes the import\'s state as appropriate' do
      expect { subject.perform(import.id) }.to change { import.reload.state.to_sym }.from(:scheduled).to(:in_progress)
    end

    it 'calls BulkImportService' do
      subject.perform(import.id)
      expect(service_double).to have_received(:call).with(import)
    end
  end
end