From 4b6558e7e5c5b5cf9d7d6dae3368715c8d4b9d43 Mon Sep 17 00:00:00 2001 From: Josh Knowles Date: Sun, 28 Dec 2008 20:53:33 -0500 Subject: [PATCH] Properly set referer and redirect to proper location --- lib/webrat/rails.rb | 8 ++++++-- spec/webrat/rails/rails_session_spec.rb | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/webrat/rails.rb b/lib/webrat/rails.rb index ce9477b..4df6cfe 100644 --- a/lib/webrat/rails.rb +++ b/lib/webrat/rails.rb @@ -90,9 +90,13 @@ module ActionController #:nodoc: def follow_redirect_with_headers(h = {}) raise "Not a redirect! #{@status} #{@status_message}" unless redirect? - h['HTTP_REFERER'] = current_url if current_url - get(interpret_uri(headers["location"].first), {}, h) + h['HTTP_REFERER'] = request.url + + location = headers["location"] + location = location.first if location.is_a?(Array) + + get(location, {}, h) status end end diff --git a/spec/webrat/rails/rails_session_spec.rb b/spec/webrat/rails/rails_session_spec.rb index bb89bad..90c7cc3 100644 --- a/spec/webrat/rails/rails_session_spec.rb +++ b/spec/webrat/rails/rails_session_spec.rb @@ -131,6 +131,7 @@ describe ActionController::Integration::Session do before :each do Webrat.configuration.mode = :rails @integration_session = ActionController::Integration::Session.new + @integration_session.stub!(:request => mock("request", :url => "http://source.url/")) @integration_session.stub!(:response => mock("response")) end @@ -167,8 +168,6 @@ describe ActionController::Integration::Session do end it "should set the HTTP referer header" do - @integration_session.stub!(:current_url).and_return "http://source.url/" - headers = {} @integration_session.follow_redirect_with_headers(headers)