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)