Add Errno::EHOSTUNREACH to Podcasts's rescue list (#16884)

* Add Errno::EHOSTUNREACH to Podcasts's rescue list

* Add spec
This commit is contained in:
Mac Siri 2022-03-15 14:05:04 -04:00 committed by GitHub
parent dc903f836c
commit b81d8c9479
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -26,7 +26,7 @@ module Podcasts
end
podcast.update_columns(reachable: true, status_notice: "")
feed.items.size
rescue Net::OpenTimeout, Errno::ECONNREFUSED, SocketError, HTTParty::RedirectionTooDeep
rescue Net::OpenTimeout, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, HTTParty::RedirectionTooDeep
set_unreachable(status: :unreachable, force_update: force_update)
rescue OpenSSL::SSL::SSLError
set_unreachable(status: :ssl_failed, force_update: force_update)

View file

@ -35,6 +35,15 @@ RSpec.describe Podcasts::Feed, type: :service, vcr: vcr_option do
expect(unpodcast.status_notice).to include("is not reachable")
end
it "sets reachable when hitting ip issue" do
allow(HTTParty).to receive(:get).with("http://podcast.example.com/podcast", httparty_options).and_raise(
Errno::EHOSTUNREACH,
)
described_class.new(unpodcast).get_episodes(limit: 2)
unpodcast.reload
expect(unpodcast.reachable).to be false
end
it "sets reachable when there redirection is too deep" do
allow(HTTParty).to receive(:get).with("http://podcast.example.com/podcast", httparty_options).and_raise(
HTTParty::RedirectionTooDeep, "too deep"