Skip to content

Commit 756c161

Browse files
committed
Add test for raising errors
Ref bookingexperts/monorepo#22238
1 parent 1d4fc41 commit 756c161

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/backgrounder/workers/process_asset_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,25 @@
7171
expect(worker.column).to eql(:avatar)
7272
end
7373
end
74+
75+
describe '#perform raises errors' do
76+
let(:admin) { double('Admin') }
77+
let(:avatar) { double('AdminAsset') }
78+
let(:worker) { worker_class.new }
79+
80+
before do
81+
allow(admin).to receive(:find).with('23').and_return(admin).once
82+
allow(admin).to receive(:avatar).twice.and_return(avatar)
83+
84+
expect(admin).to receive(:process_avatar_upload=).with(true).once
85+
expect(avatar).to receive(:recreate_versions!).once.and_return(nil)
86+
expect(avatar).to receive(:file).and_return(avatar)
87+
end
88+
89+
it 'raises an runtime error' do
90+
expect { worker.perform admin, '23', :avatar }.to raise_error(RuntimeError, 'Failed to recreate versions')
91+
end
92+
end
7493
end
94+
95+

0 commit comments

Comments
 (0)