suspension_worker_spec.rb 657 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Admin::SuspensionWorker do
  4. let(:worker) { described_class.new }
  5. let(:service) { instance_double(SuspendAccountService, call: true) }
  6. describe '#perform' do
  7. before do
  8. allow(SuspendAccountService).to receive(:new).and_return(service)
  9. end
  10. let(:account) { Fabricate(:account) }
  11. it 'sends the account to the service' do
  12. worker.perform(account.id)
  13. expect(service).to have_received(:call).with(account)
  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