Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure TestRequest#request_uri returns the right value when doing mul…

…tiple GETs. Closes #4867 [alisdair@randomoracle.org, mpalmer]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7320 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 2503fd3c3a53974ce4550679b4c6f6b5304ea9f8 1 parent 631bf6b
@NZKoz NZKoz authored
View
7 actionpack/lib/action_controller/test_process.rb
@@ -24,6 +24,7 @@ class TestRequest < AbstractRequest #:nodoc:
attr_accessor :cookies, :session_options
attr_accessor :query_parameters, :request_parameters, :path, :session, :env
attr_accessor :host
+ attr_reader :request_uri_overridden
def initialize(query_parameters = nil, request_parameters = nil, session = nil)
@query_parameters = query_parameters || {}
@@ -67,12 +68,14 @@ def action=(action_name)
# Used to check AbstractRequest's request_uri functionality.
# Disables the use of @path and @request_uri so superclass can handle those.
def set_REQUEST_URI(value)
+ @request_uri_overridden = true
@env["REQUEST_URI"] = value
@request_uri = nil
@path = nil
end
def request_uri=(uri)
+ @env["REQUEST_URI"] = uri
@request_uri = uri
@path = uri.split("?").first
end
@@ -426,12 +429,12 @@ def redirect_to_url
end
def build_request_uri(action, parameters)
- unless @request.env['REQUEST_URI']
+ unless @request.request_uri_overridden
options = @controller.send(:rewrite_options, parameters)
options.update(:only_path => true, :action => action)
url = ActionController::UrlRewriter.new(@request, parameters)
- @request.set_REQUEST_URI(url.rewrite(options))
+ @request.request_uri = url.rewrite(options)
end
end
View
16 actionpack/test/controller/test_test.rb
@@ -482,6 +482,22 @@ def test_redirect_url_only_cares_about_location_header
end
end
+ def test_request_uri_updates
+ get :test_params
+ uri = @request.request_uri
+ assert_equal @request.env['REQUEST_URI'], uri
+
+ get :test_uri
+ assert_not_equal uri, @request.request_uri
+ uri = @request.request_uri
+ assert_equal @request.env['REQUEST_URI'], uri
+
+ get :test_uri, :testing => true
+ assert_not_equal uri, @request.request_uri
+ uri = @request.request_uri
+ assert_equal @request.env['REQUEST_URI'], uri
+ end
+
protected
def with_foo_routing
with_routing do |set|
Please sign in to comment.
Something went wrong with that request. Please try again.