aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/test_process.rb2
-rw-r--r--actionpack/test/controller/test_test.rb19
3 files changed, 22 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index a064526e06..8d5ee81c63 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* @response.redirect_url works with 201 Created responses: just return headers['Location'] rather than checking the response status. [Jeremy Kemper]
+
* Added CSV to Mime::SET so that respond_to csv will work [Cody Fauser]
* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH]
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 924d032eec..4011e6cf33 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -179,7 +179,7 @@ module ActionController #:nodoc:
# returns the redirection location or nil
def redirect_url
- redirect? ? headers['Location'] : nil
+ headers['Location']
end
# does the redirect location match this regexp pattern?
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index ee172b25a4..bc2651c281 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -66,6 +66,11 @@ HTML
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 @@ HTML
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|