Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

A better patch for Rails 3 controller redirects #52

Merged
merged 3 commits into from

3 participants

@dlibanori

Actually this is a patch for Rack applications redirects.

This patch changes current specs and shows where they fail.

I think it is not so hard coded as forcing mock session to comply with Rack::Test 'example.org' url.

@dlisboa

+1

@indirect indirect merged commit 55c9a99 into brynary:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  lib/webrat/adapters/rack.rb
@@ -4,6 +4,7 @@ module Webrat
class RackAdapter
extend Forwardable
+ attr :session
def_delegators :@session, :get, :post, :put, :delete
def initialize(session) #:nodoc:
View
8 lib/webrat/core/session.rb
@@ -286,11 +286,15 @@ def response_location
end
def current_host
- URI.parse(current_url).host || @custom_headers["Host"] || "www.example.com"
+ URI.parse(current_url).host || @custom_headers["Host"] || default_current_host
end
def response_location_host
- URI.parse(response_location).host || "www.example.com"
+ URI.parse(response_location).host || default_current_host
+ end
+
+ def default_current_host
+ adapter.session.rack_mock_session.default_host
end
def reset
View
2  spec/integration/rack/test/webrat_rack_test.rb
@@ -8,7 +8,7 @@ class WebratRackTest < Test::Unit::TestCase
include Webrat::HaveTagMatcher
def build_rack_mock_session
- Rack::MockSession.new(app, "www.example.com")
+ Rack::MockSession.new(app, "example.net")
end
def test_visits_pages
Something went wrong with that request. Please try again.