removing the normalization of url's for the rails session. stipping them of host, port, and anchors is not really needed, especially since josh's redirect change to stop when going to a different host. See comments here: http://webrat.lighthouseapp.com/projects/10503-webrat/tickets/132

This commit is contained in:
Adam Greene 2009-01-16 12:18:22 -08:00 committed by Josh Knowles
parent 4e3cf59920
commit 4fc2b7eb7e
2 changed files with 10 additions and 17 deletions

View File

@ -65,19 +65,11 @@ module Webrat
@context @context
end end
#now that we are not following external links, do NOT normalize the url and strip it of its host
#once we get here we don't care about stripping out the host because we know
def do_request(http_method, url, data, headers) #:nodoc: def do_request(http_method, url, data, headers) #:nodoc:
update_protocol(url) update_protocol(url)
integration_session.send(http_method, normalize_url(url), data, headers) integration_session.send(http_method, url, data, headers)
end
# remove protocol, host and anchor
def normalize_url(href) #:nodoc:
uri = URI.parse(href)
normalized_url = uri.path
if uri.query
normalized_url += "?" + uri.query
end
normalized_url
end end
def update_protocol(href) #:nodoc: def update_protocol(href) #:nodoc:

View File

@ -6,6 +6,7 @@ describe Webrat::RailsSession do
before :each do before :each do
Webrat.configuration.mode = :rails Webrat.configuration.mode = :rails
@integration_session = mock("integration_session") @integration_session = mock("integration_session")
@integration_session.stub!(:response => mock("response", :body => "<html>", :code => '200'))
end end
it "should delegate response_body to the session response body" do it "should delegate response_body to the session response body" do
@ -43,18 +44,18 @@ describe Webrat::RailsSession do
end end
context "the URL is a full path" do context "the URL is a full path" do
it "should just pass on the path" do it "should pass the full url" do
@integration_session.stub!(:https!) @integration_session.stub!(:https!)
@integration_session.should_receive(:get).with("/url", "data", "headers") @integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("http://www.example.com/url", "data", "headers") rails_session.get("http://www.example.com/url", "data", "headers")
end end
end end
context "the URL is https://" do context "the URL is https://" do
it "should call #https! with true before the request and just pass on the path" do it "should call #https! with true before the request before passing along the full url" do
@integration_session.should_receive(:https!).with(true) @integration_session.should_receive(:https!).with(true)
@integration_session.should_receive(:get).with("/url", "data", "headers") @integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("https://www.example.com/url", "data", "headers") rails_session.get("https://www.example.com/url", "data", "headers")
end end
@ -70,9 +71,9 @@ describe Webrat::RailsSession do
end end
context "the URL include an anchor" do context "the URL include an anchor" do
it "should strip out the anchor" do it "should keep the anchor" do
@integration_session.should_receive(:https!).with(false) @integration_session.should_receive(:https!).with(false)
@integration_session.should_receive(:get).with("/url", "data", "headers") @integration_session.should_receive(:get).with("http://www.example.com/url#foo", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("http://www.example.com/url#foo", "data", "headers") rails_session.get("http://www.example.com/url#foo", "data", "headers")
end end