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
|
@ -2,12 +2,38 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PostProcessMediaWorker do
|
||||
describe PostProcessMediaWorker, :paperclip_processing do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe 'perform' do
|
||||
it 'runs without error for missing record' do
|
||||
expect { worker.perform(nil) }.to_not raise_error
|
||||
describe '#perform' do
|
||||
let(:media_attachment) { Fabricate(:media_attachment) }
|
||||
|
||||
it 'reprocesses and updates the media attachment' do
|
||||
worker.perform(media_attachment.id)
|
||||
|
||||
expect(media_attachment.processing).to eq('complete')
|
||||
end
|
||||
|
||||
it 'returns true for non-existent record' do
|
||||
result = worker.perform(123_123_123)
|
||||
|
||||
expect(result).to be(true)
|
||||
end
|
||||
|
||||
context 'when sidekiq retries are exhausted' do
|
||||
it 'sets state to failed' do
|
||||
described_class.within_sidekiq_retries_exhausted_block({ 'args' => [media_attachment.id] }) do
|
||||
worker.perform(media_attachment.id)
|
||||
end
|
||||
|
||||
expect(media_attachment.reload.processing).to eq('failed')
|
||||
end
|
||||
|
||||
it 'returns true for non-existent record' do
|
||||
described_class.within_sidekiq_retries_exhausted_block({ 'args' => [123_123_123] }) do
|
||||
expect(worker.perform(123_123_123)).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue