diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2006-03-08 20:12:30 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2006-03-08 20:12:30 +0000 |
commit | aafc191ab7d7a9c4f733446c073b41ff79c34135 (patch) | |
tree | ef0d481edc837c72a6e267397e270829e236537d /actionpack/lib/action_controller | |
parent | 47ffc04621c4ce5cbf491091d3680e8e34e674b7 (diff) | |
download | rails-aafc191ab7d7a9c4f733446c073b41ff79c34135.tar.gz rails-aafc191ab7d7a9c4f733446c073b41ff79c34135.tar.bz2 rails-aafc191ab7d7a9c4f733446c073b41ff79c34135.zip |
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
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/integration_test.rb | 15 |
1 files changed, 5 insertions, 10 deletions
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) |