Properly set referer and redirect to proper location

This commit is contained in:
Josh Knowles 2008-12-28 20:53:33 -05:00
parent 29274f9b4b
commit 4b6558e7e5
2 changed files with 7 additions and 4 deletions

View File

@ -90,9 +90,13 @@ module ActionController #:nodoc:
def follow_redirect_with_headers(h = {}) def follow_redirect_with_headers(h = {})
raise "Not a redirect! #{@status} #{@status_message}" unless redirect? 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 status
end end
end end

View File

@ -131,6 +131,7 @@ describe ActionController::Integration::Session do
before :each do before :each do
Webrat.configuration.mode = :rails Webrat.configuration.mode = :rails
@integration_session = ActionController::Integration::Session.new @integration_session = ActionController::Integration::Session.new
@integration_session.stub!(:request => mock("request", :url => "http://source.url/"))
@integration_session.stub!(:response => mock("response")) @integration_session.stub!(:response => mock("response"))
end end
@ -167,8 +168,6 @@ describe ActionController::Integration::Session do
end end
it "should set the HTTP referer header" do it "should set the HTTP referer header" do
@integration_session.stub!(:current_url).and_return "http://source.url/"
headers = {} headers = {}
@integration_session.follow_redirect_with_headers(headers) @integration_session.follow_redirect_with_headers(headers)