Improve spec coverage for collection of workers/
classes (#27874)
This commit is contained in:
parent
0a6ec048a8
commit
155fb84141
16 changed files with 460 additions and 8 deletions
42
spec/workers/delete_mute_worker_spec.rb
Normal file
42
spec/workers/delete_mute_worker_spec.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe DeleteMuteWorker do
|
||||
let(:worker) { described_class.new }
|
||||
let(:service) { instance_double(UnmuteService, call: true) }
|
||||
|
||||
describe '#perform' do
|
||||
before do
|
||||
allow(UnmuteService).to receive(:new).and_return(service)
|
||||
end
|
||||
|
||||
context 'with an expired mute' do
|
||||
let(:mute) { Fabricate(:mute, expires_at: 1.day.ago) }
|
||||
|
||||
it 'sends the mute to the service' do
|
||||
worker.perform(mute.id)
|
||||
|
||||
expect(service).to have_received(:call).with(mute.account, mute.target_account)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an unexpired mute' do
|
||||
let(:mute) { Fabricate(:mute, expires_at: 1.day.from_now) }
|
||||
|
||||
it 'does not send the mute to the service' do
|
||||
worker.perform(mute.id)
|
||||
|
||||
expect(service).to_not have_received(:call)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a non-existent mute' do
|
||||
it 'does not send the mute to the service' do
|
||||
worker.perform(123_123_123)
|
||||
|
||||
expect(service).to_not have_received(:call)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue