diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-19 14:36:06 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-19 14:36:06 +0000 |
commit | f4e16a6a5fd363c145a26e91bdf8d87821772f80 (patch) | |
tree | 90a082067f7705d8ad0b5dafba503be85c1716d4 /spec/controllers/application_controller_spec.rb | |
parent | 63c5ed67bf023852b121993d0fc7ce62e0be1023 (diff) | |
parent | b2618cc78e86176c13e2b4197d56270242680884 (diff) |
Merge branch 'wdtk' of github.com:sebbacon/alaveteli into wdtk
Diffstat (limited to 'spec/controllers/application_controller_spec.rb')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 0a1d57f0c..f16cee312 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -2,6 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'fakeweb' describe ApplicationController, "when accessing third party services" do + before (:each) do + FakeWeb.clean_registry + end + after (:each) do + FakeWeb.clean_registry + end + 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 +28,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|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 |