aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-18 11:07:50 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-18 11:07:50 +0000
commit46a8ec0fae82f8bc74077c4754b35aa0bd9a5ccd (patch)
treed1d9db41c32315c0ca77fa56dfca42253740507f
parent936c3b2fb1365e46239ff98ab962460d0c459730 (diff)
Fix more test breakage
-rw-r--r--spec/controllers/application_controller_spec.rb8
-rw-r--r--spec/spec_helper.rb7
2 files changed, 12 insertions, 3 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 8c3730a7e..2e0e99200 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -2,6 +2,12 @@ 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'
@@ -22,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|http://500.com|, :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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a290ab5bb..33a28449e 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -143,7 +143,10 @@ if $tempfilecount.nil?
module TestProcess
# Hook into the process function, so can automatically get HTML after each request
alias :original_process :process
-
+ def is_fragment
+ # XXX there must be a better way of doing this!
+ return @request.query_parameters["action"] == "search_typeahead"
+ end
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
self.original_process(action, parameters, session, flash, http_method)
# don't validate auto-generated HTML
@@ -152,7 +155,7 @@ if $tempfilecount.nil?
return unless @response.template.controller.instance_eval { integrate_views? }
# And then if HTML, not a redirect (302, 301)
if @response.content_type == "text/html" && ! [301,302,401].include?(@response.response_code)
- if @response.template.instance_eval("@_memoized__pick_partial_template").nil?
+ if !is_fragment
validate_html(@response.body)
else
# it's a partial