rescue Addressable::URI::InvalidURIError and mark podcast ep unreachable (#7343)
This commit is contained in:
parent
1b93666b3b
commit
3832e9356d
2 changed files with 10 additions and 1 deletions
|
|
@ -35,7 +35,7 @@ module Podcasts
|
|||
def url_reachable?(url)
|
||||
url = Addressable::URI.parse(url).normalize.to_s
|
||||
HTTParty.head(url).code == 200
|
||||
rescue Net::OpenTimeout, SystemCallError, URI::InvalidURIError
|
||||
rescue Net::OpenTimeout, SystemCallError, URI::InvalidURIError, Addressable::URI::InvalidURIError
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -74,4 +74,13 @@ RSpec.describe Podcasts::GetMediaUrl, type: :service do
|
|||
expect(result.reachable).to be false
|
||||
expect(result.url).to eq(http_url)
|
||||
end
|
||||
|
||||
it "marks unreachable with addressable invalid url exception" do
|
||||
allow(HTTParty).to receive(:head).with(https_url).and_raise(Addressable::URI::InvalidURIError)
|
||||
allow(HTTParty).to receive(:head).with(http_url).and_raise(Addressable::URI::InvalidURIError)
|
||||
result = described_class.call(http_url)
|
||||
expect(result.https).to be false
|
||||
expect(result.reachable).to be false
|
||||
expect(result.url).to eq(http_url)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue