From aafc191ab7d7a9c4f733446c073b41ff79c34135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Wed, 8 Mar 2006 20:12:30 +0000 Subject: Integration test's url_for now runs in the context of the last request (if any) so after post /products/show/1 url_for :action => 'new' will yield /product/new git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3819 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/integration_test.rb | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_controller/integration_test.rb') diff --git a/actionpack/lib/action_controller/integration_test.rb b/actionpack/lib/action_controller/integration_test.rb index 5fce6183a4..6cca3ff4a3 100644 --- a/actionpack/lib/action_controller/integration_test.rb +++ b/actionpack/lib/action_controller/integration_test.rb @@ -80,9 +80,7 @@ module ActionController # session.https! # session.https!(false) def https!(flag=true) - @https = flag - initialize_url_writer - @https + @https = flag end # Return +true+ if the session is mimicing a secure HTTPS request. @@ -99,8 +97,6 @@ module ActionController # session.host! "www.example.test" def host!(name) @host = name - initialize_url_writer - @host end # To make setting the host more natural when using a session object @@ -165,7 +161,7 @@ module ActionController # Returns the URL for the given options, according to the rules specified # in the application's routes. def url_for(options) - @rewriter.rewrite(options) + controller ? controller.url_for(options) : generic_url_rewriter.rewrite(options) end private @@ -267,16 +263,15 @@ module ActionController end end - # Initialize the URL writer object that will be used to generate - # URL's. - def initialize_url_writer + # Get a temporarly URL writer object + def generic_url_rewriter cgi = MockCGI.new('REQUEST_METHOD' => "GET", 'QUERY_STRING' => "", "REQUEST_URI" => "/", "HTTP_HOST" => host, "SERVER_PORT" => https? ? "443" : "80", "HTTPS" => https? ? "on" : "off") - @rewriter = ActionController::UrlRewriter.new(ActionController::CgiRequest.new(cgi), {}) + ActionController::UrlRewriter.new(ActionController::CgiRequest.new(cgi), {}) end def name_with_prefix(prefix, name) -- cgit v1.2.3