From 5324c01209c77ec0ab1c882e155121a0ddb0839d Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 27 Sep 2017 14:52:49 +0800 Subject: [PATCH] FIX: Don't raise an error if reading from URL timeout. --- lib/final_destination.rb | 2 ++ spec/components/final_destination_spec.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/final_destination.rb b/lib/final_destination.rb index f74ff6cca0f..1a732a952a2 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -123,6 +123,8 @@ class FinalDestination return resolve end + nil + rescue Excon::Errors::Timeout nil end diff --git a/spec/components/final_destination_spec.rb b/spec/components/final_destination_spec.rb index e198b1e766b..d9fcba70a73 100644 --- a/spec/components/final_destination_spec.rb +++ b/spec/components/final_destination_spec.rb @@ -53,11 +53,17 @@ describe FinalDestination do expect(fd('https://eviltrout.com').status).to eq(:ready) end - it "returns nil an invalid url" do + it "returns nil for an invalid url" do expect(fd(nil).resolve).to be_nil expect(fd('asdf').resolve).to be_nil end + it "returns nil when read timeouts" do + Excon.expects(:public_send).raises(Excon::Errors::Timeout) + + expect(fd('https://discourse.org').resolve).to eq(nil) + end + context "without redirects" do before do stub_request(:head, "https://eviltrout.com").to_return(doc_response)