From 8cda77318ce8a1381fb918173224c86b8827d2d9 Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Wed, 24 Jun 2009 15:19:06 +0200 Subject: [PATCH] Fix wrong HTTP_HOST in rack session Webrat relies on www.example.com while Rack::Test expects example.org --- lib/webrat/rack.rb | 2 ++ spec/integration/rack/test/webrat_rack_test.rb | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/webrat/rack.rb b/lib/webrat/rack.rb index cb6789a..49bbfca 100644 --- a/lib/webrat/rack.rb +++ b/lib/webrat/rack.rb @@ -1,5 +1,7 @@ require "rack/test" +Rack::Test::DEFAULT_HOST.replace("www.example.com") + module Webrat class RackSession < Session def initialize(rack_test_session) #:nodoc: diff --git a/spec/integration/rack/test/webrat_rack_test.rb b/spec/integration/rack/test/webrat_rack_test.rb index 8d7fbdb..4fdef09 100644 --- a/spec/integration/rack/test/webrat_rack_test.rb +++ b/spec/integration/rack/test/webrat_rack_test.rb @@ -17,10 +17,10 @@ class WebratRackTest < Test::Unit::TestCase assert_equal "/", last_request.env["PATH_INFO"] end - # def test_redirects - # visit "/redirect_absolute_url" - # assert_equal "spam", response_body - # end + def test_redirects + visit "/redirect_absolute_url" + assert_equal "spam", response_body + end def test_assertions_after_visit visit "/"