FIX: skip invalid URLs when checking for audio/video in search blurbs

Fixes 500 errors on search queries introduced in 580a4a8
This commit is contained in:
Penar Musaraj
2019-11-06 10:32:15 -05:00
parent b869ef8a76
commit 0dfc594784
2 changed files with 16 additions and 7 deletions

View File

@ -28,7 +28,7 @@ describe Search do
expect(result).to eq("link to an external page: https://google.com/?u=bar link to an audio file: #{I18n.t("search.audio")} link to a video file: #{I18n.t("search.video")}")
end
it "strips URLs correctly when blurb is" do
it "strips URLs correctly when blurb is longer than limit" do
cooked = <<~RAW
Here goes a test cooked with enough characters to hit the blurb limit.
@ -41,6 +41,13 @@ describe Search do
expect(result).to eq("Here goes a test cooked with enough characters to hit the blurb limit. Something is very interesting about this audio file. #{I18n.t("search.audio")}")
end
it "does not fail on bad URLs" do
cooked = <<~RAW
invalid URL: http:error] should not trip up blurb generation.
RAW
result = Search::GroupedSearchResults.blurb_for(cooked)
expect(result).to eq("invalid URL: http:error] should not trip up blurb generation.")
end
end
end