aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2006-03-08 20:12:30 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2006-03-08 20:12:30 +0000
commitaafc191ab7d7a9c4f733446c073b41ff79c34135 (patch)
treeef0d481edc837c72a6e267397e270829e236537d /actionpack
parent47ffc04621c4ce5cbf491091d3680e8e34e674b7 (diff)
downloadrails-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')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/integration_test.rb15
2 files changed, 7 insertions, 10 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index ac34e2ef21..222ed04d50 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* 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 [Tobias Luetke]
+
* Re-added mixed-in helper methods for the JavascriptGenerator. Moved JavascriptGenerators methods to a module that is mixed in after the helpers are added. Also fixed that variables set in the enumeration methods like #collect are set correctly. Documentation added for the enumeration methods [Rick Olson]. Examples:
page.select('#items li').collect('items') do |element|
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)