diff options
author | Jonne Haß <me@jhass.eu> | 2014-09-20 17:12:56 +0400 |
---|---|---|
committer | Jonne Haß <me@jhass.eu> | 2014-09-20 17:13:14 +0400 |
commit | d6f5368474240a394a5c952769480cad69093a89 (patch) | |
tree | 5fb6c564d0069863f77a18d423cbc8158ae54057 | |
parent | 499ff6e0f463d7fdd53119d76b1aa444f0ddd7c1 (diff) |
Handle already deleted photos gracefully in process photo job
-rw-r--r-- | app/workers/process_photo.rb | 1 | ||||
-rw-r--r-- | spec/workers/process_photo_spec.rb | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/workers/process_photo.rb b/app/workers/process_photo.rb index 00d959962..2fcdd3943 100644 --- a/app/workers/process_photo.rb +++ b/app/workers/process_photo.rb @@ -16,6 +16,7 @@ module Workers photo.processed_image.store!(unprocessed_image) photo.save! + rescue ActiveRecord::RecordNotFound # Deleted before the job was run end end end diff --git a/spec/workers/process_photo_spec.rb b/spec/workers/process_photo_spec.rb index 8294902ca..8e28fba74 100644 --- a/spec/workers/process_photo_spec.rb +++ b/spec/workers/process_photo_spec.rb @@ -61,6 +61,12 @@ describe Workers::ProcessPhoto do expect{ result = Workers::ProcessPhoto.new.perform(p.id) }.to_not raise_error - + + end + + it 'handles already deleted photos gracefully' do + expect { + Workers::ProcessPhoto.new.perform(0) + }.to_not raise_error end end |