From 74ca9b8cb0fd996d1e2bbdc8927baacb73a3b4c4 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Elomar=20Fran=C3=A7a?= Date: Sun, 27 Sep 2009 18:05:59 -0300 Subject: [PATCH] In integration tests, setting the HTTP_REFERER header to the url of the last request --- .../lib/action_dispatch/testing/integration.rb | 3 ++- actionpack/test/controller/integration_test.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 9f7877f..7a3443d 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -264,7 +264,8 @@ module ActionDispatch "HTTP_HOST" => host, "REMOTE_ADDR" => remote_addr, "CONTENT_TYPE" => "application/x-www-form-urlencoded", - "HTTP_ACCEPT" => accept + "HTTP_ACCEPT" => accept, + "HTTP_REFERER" => @request ? @request.url : nil } (rack_environment || {}).each do |key, value| diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 0e4ca21..07f7e6e 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -245,6 +245,10 @@ class IntegrationProcessTest < ActionController::IntegrationTest def redirect redirect_to :action => "get" end + + def redirect_to_back + redirect_to :back + end end def test_get @@ -312,6 +316,19 @@ class IntegrationProcessTest < ActionController::IntegrationTest end end + def test_redirect_to_back + with_test_route_set do + get '/get' + get '/redirect' + assert_equal 302, status + assert_equal 2, request_count + + follow_redirect! + assert_response :success + assert_equal "/get", path + end + end + def test_xml_http_request_get with_test_route_set do xhr :get, '/get' -- 1.6.3.1