FIX: Use find_by_id method to prevent record not found exception

This commit is contained in:
Vinoth Kannan 2018-12-15 03:19:45 +05:30
parent 430083019d
commit 0d3c1cde90
2 changed files with 7 additions and 1 deletions

View File

@ -513,7 +513,7 @@ class CookedPostProcessor
end
upload_id = downloaded_images[src]
upload = Upload.find(upload_id) if upload_id
upload = Upload.find_by_id(upload_id) if upload_id
img["src"] = upload.url if upload.present?
# make sure we grab dimensions for oneboxed images

View File

@ -778,6 +778,12 @@ describe CookedPostProcessor do
cpp.post_process_oneboxes
expect(cpp.doc.to_s).to eq("<p><img class=\"onebox\" src=\"#{upload.url}\" width=\"\" height=\"\"></p>")
upload.destroy
cpp = CookedPostProcessor.new(post, invalidate_oneboxes: true)
cpp.post_process_oneboxes
expect(cpp.doc.to_s).to eq("<p><img class=\"onebox\" src=\"#{image_url}\" width=\"\" height=\"\"></p>")
end
it "replaces large image placeholder" do