From a41476800b37e8f9ad467940d154b3c8ba58788c Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Thu, 28 May 2020 11:59:20 -0300 Subject: [PATCH] FIX: Don't raise an exception if a topic cannot be retrieved (#9906) --- app/models/topic_embed.rb | 2 +- spec/models/topic_embed_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb index d8aef830806..7529e98353e 100644 --- a/app/models/topic_embed.rb +++ b/app/models/topic_embed.rb @@ -116,7 +116,7 @@ class TopicEmbed < ActiveRecord::Base ) url = fd.resolve - raise URI::InvalidURIError if url.blank? + return if url.blank? opts = { tags: %w[div p code pre h1 h2 h3 b em i strong a img ul li ol blockquote], diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb index cfdddd389b0..bc061ddcbe4 100644 --- a/spec/models/topic_embed_spec.rb +++ b/spec/models/topic_embed_spec.rb @@ -311,9 +311,10 @@ describe TopicEmbed do end context "non-http URL" do - let(:url) { '/test.txt' } it "throws an error" do - expect { TopicEmbed.find_remote(url) }.to raise_error(URI::InvalidURIError) + url = '/test.txt' + + expect(TopicEmbed.find_remote(url)).to be_nil end end