Skip to content

Commit

Permalink
fix: Rescue when blob is not found when using repair url (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandfardeau authored Aug 22, 2023
1 parent ac9d200 commit 148aee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/decidim/content_fixer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def new_source(source)

def find_service_url_for_blob(blob_id)
Rails.application.routes.url_helpers.rails_blob_path(ActiveStorage::Blob.find(blob_id), only_path: true)
rescue ActiveRecord::RecordNotFound
@logger.warn "Blob #{blob_id} not found"
nil
end

def nokogiri_will_wrap_with_p?(content)
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/decidim/content_fixer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,11 @@
it "returns the service url for the given blob" do
expect(subject.find_service_url_for_blob(blob.id)).to eq(blob_path)
end

context "when blob is not found" do
it "returns nil" do
expect(subject.find_service_url_for_blob(blob.id + 1)).to eq(nil)
end
end
end
end

0 comments on commit 148aee8

Please sign in to comment.