Permalink
Browse files

Use Rack::Head middleware to ensure the body is discarded for HEAD re…

…quests
  • Loading branch information...
1 parent 63b4fe5 commit 5b5d0e325d9b031638c0cebb128f2acc3dd764c4 @josh josh committed Feb 1, 2009
@@ -26,6 +26,9 @@ class Session
# The status message that accompanied the status code of the last request.
attr_reader :status_message
+ # The body of the last request.
+ attr_reader :body
+
# The URI of the last request.
attr_reader :path
@@ -19,3 +19,4 @@
use "ActionController::RewindableInput"
use "ActionController::ParamsParser"
use "Rack::MethodOverride"
+use "Rack::Head"
@@ -266,6 +266,7 @@ def test_get
assert_response :success
assert_response :ok
assert_equal({}, cookies)
+ assert_equal "OK", body
assert_equal "OK", response.body
assert_kind_of HTML::Document, html_document
assert_equal 1, request_count
@@ -281,6 +282,7 @@ def test_post
assert_response :success
assert_response :created
assert_equal({}, cookies)
+ assert_equal "Created", body
assert_equal "Created", response.body
assert_kind_of HTML::Document, html_document
assert_equal 1, request_count
@@ -360,6 +362,18 @@ def test_get_with_parameters
end
end
+ def test_head
+ with_test_route_set do
+ head '/get'
+ assert_equal 200, status
+ assert_equal "", body
+
+ head '/post'
+ assert_equal 201, status
+ assert_equal "", body
+ end
+ end
+
private
def with_test_route_set
with_routing do |set|

0 comments on commit 5b5d0e3

Please sign in to comment.