Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge [5643] from trunk.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5644 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit b2ae346484ada91a2a4b0a862e5985b6ac113320 1 parent fb6cd55
@jeremy jeremy authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.13.0 RC1* (November 22nd, 2006)
+* @response.redirect_url works with 201 Created responses: just return headers['Location'] rather than checking the response status. [Jeremy Kemper]
+
* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH]
* Added GET-masquarading for HEAD, so request.method will return :get even for HEADs. This will help anyone relying on case request.method to automatically work with HEAD and map.resources will also allow HEADs to all GET actions. Rails automatically throws away the response content in a reply to HEAD, so you don't even need to worry about that. If you, for whatever reason, still need to distinguish between GET and HEAD in some edge case, you can use Request#head? and even Request.headers["REQUEST_METHOD"] for get the "real" answer. Closes #6694 [DHH]
View
2  actionpack/lib/action_controller/test_process.rb
@@ -179,7 +179,7 @@ def error?
# returns the redirection location or nil
def redirect_url
- redirect? ? headers['Location'] : nil
+ headers['Location']
end
# does the redirect location match this regexp pattern?
View
19 actionpack/test/controller/test_test.rb
@@ -66,6 +66,11 @@ def redirect_to_different_controller
redirect_to :controller => 'fail', :id => 5
end
+ def create
+ headers['Location'] = 'created resource'
+ head :created
+ end
+
private
def rescue_action(e)
raise e
@@ -463,6 +468,20 @@ def test_assert_follow_redirect_to_different_controller
end
end
+ def test_redirect_url_only_cares_about_location_header
+ get :create
+ assert_response :created
+
+ # Redirect url doesn't care that it wasn't a :redirect response.
+ assert_equal 'created resource', @response.redirect_url
+ assert_equal @response.redirect_url, redirect_to_url
+
+ # Must be a :redirect response.
+ assert_raise(Test::Unit::AssertionFailedError) do
+ assert_redirected_to 'created resource'
+ end
+ end
+
protected
def with_foo_routing
with_routing do |set|
Please sign in to comment.
Something went wrong with that request. Please try again.