Skip to content

Commit 3e9a560

Browse files
committed
make sure to raise error if service is unreachable (with or without a retry)
1 parent e334a6c commit 3e9a560

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/intercom.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def self.target_base_url
5353

5454
def self.send_request_to_path(request)
5555
request.execute(target_base_url)
56-
rescue Intercom::ServiceReachableError
56+
rescue Intercom::ServiceReachableError => e
5757
if @endpoints && @endpoints.length > 1
58-
@endpoints = @endpoints.rotate
5958
request.execute(target_base_url)
59+
else
60+
raise e
6061
end
61-
6262
end
6363

6464
def self.post(path, payload_hash)

spec/integration/intercom_api_integration_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@
5757

5858
it "should failover to good endpoint when first one is un-reachable" do
5959
Intercom.endpoints = ["http://127.0.0.7", "https://api.intercom.io"]
60-
6160
user = Intercom::User.find(:email => "[email protected]")
6261
user.name.must_equal "Somebody"
6362
end
63+
64+
it "should raise error when endpoint(s) are un-reachable" do
65+
Intercom.endpoints = ["http://127.0.0.7"]
66+
proc { Intercom::User.find(:email => "[email protected]")}.must_raise Intercom::ServiceReachableError
67+
Intercom.endpoints = ["http://127.0.0.7", "http://127.0.0.6"]
68+
proc { Intercom::User.find(:email => "[email protected]")}.must_raise Intercom::ServiceReachableError
69+
end
6470
end

0 commit comments

Comments
 (0)