diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-18 09:07:44 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-18 09:14:25 +0000 |
commit | 936c3b2fb1365e46239ff98ab962460d0c459730 (patch) | |
tree | e3ab2d063117bd88df5bfcac43cf318d9744b9db /spec/controllers/application_controller_spec.rb | |
parent | 12805e8c61ba8f6e4235800332ad80e0b2f307f7 (diff) |
Catch timeouts and other extra errors when connection to 3rd party websites fails.
Diffstat (limited to 'spec/controllers/application_controller_spec.rb')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1d6802940..8c3730a7e 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -2,6 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'fakeweb' describe ApplicationController, "when accessing third party services" do + it "should succeed if the service responds OK" do + config = MySociety::Config.load_default() + config['GAZE_URL'] = 'http://denmark.com' + FakeWeb.register_uri(:get, %r|denmark.com|, :body => "DK") + country = self.controller.send :country_from_ip + country.should == "DK" + end it "should fail silently if the country_from_ip domain doesn't exist" do config = MySociety::Config.load_default() config['GAZE_URL'] = 'http://12123sdf14qsd.com' @@ -15,7 +22,7 @@ describe ApplicationController, "when accessing third party services" do country.should == config['ISO_COUNTRY_CODE'] end it "should fail silently if the country_from_ip service returns an error" do - FakeWeb.register_uri(:get, %r|.*|, :body => "Error", :status => ["500", "Error"]) + FakeWeb.register_uri(:get, %r|http://500.com|, :body => "Error", :status => ["500", "Error"]) config = MySociety::Config.load_default() config['GAZE_URL'] = 'http://500.com' country = self.controller.send :country_from_ip |