delete_mute_worker_spec.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe DeleteMuteWorker do
  4. let(:worker) { described_class.new }
  5. let(:service) { instance_double(UnmuteService, call: true) }
  6. describe '#perform' do
  7. before do
  8. allow(UnmuteService).to receive(:new).and_return(service)
  9. end
  10. context 'with an expired mute' do
  11. let(:mute) { Fabricate(:mute, expires_at: 1.day.ago) }
  12. it 'sends the mute to the service' do
  13. worker.perform(mute.id)
  14. expect(service).to have_received(:call).with(mute.account, mute.target_account)
  15. end
  16. end
  17. context 'with an unexpired mute' do
  18. let(:mute) { Fabricate(:mute, expires_at: 1.day.from_now) }
  19. it 'does not send the mute to the service' do
  20. worker.perform(mute.id)
  21. expect(service).to_not have_received(:call)
  22. end
  23. end
  24. context 'with a non-existent mute' do
  25. it 'does not send the mute to the service' do
  26. worker.perform(123_123_123)
  27. expect(service).to_not have_received(:call)
  28. end
  29. end
  30. end
  31. end