removal_worker_spec.rb 638 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe RemovalWorker do
  4. let(:worker) { described_class.new }
  5. let(:service) { instance_double(RemoveStatusService, call: true) }
  6. describe '#perform' do
  7. before do
  8. allow(RemoveStatusService).to receive(:new).and_return(service)
  9. end
  10. let(:status) { Fabricate(:status) }
  11. it 'sends the status to the service' do
  12. worker.perform(status.id)
  13. expect(service).to have_received(:call).with(status)
  14. end
  15. it 'returns true for non-existent record' do
  16. result = worker.perform(123_123_123)
  17. expect(result).to be(true)
  18. end
  19. end
  20. end