aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/request_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-11-23 23:24:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-11-23 23:24:47 +0000
commitefd0bdd9eaf66a361b01739522794ec0c9453d15 (patch)
tree10244d7ddfbb6718d751066c4bf8ea6cb1565e75 /actionpack/test/controller/request_test.rb
parentf15d52fc4ab921f010325adfd543c0a0c29913d2 (diff)
downloadrails-efd0bdd9eaf66a361b01739522794ec0c9453d15.tar.gz
rails-efd0bdd9eaf66a361b01739522794ec0c9453d15.tar.bz2
rails-efd0bdd9eaf66a361b01739522794ec0c9453d15.zip
* 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 dont 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]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5621 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/request_test.rb')
-rw-r--r--actionpack/test/controller/request_test.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb
index 11da23561b..65e88b74d8 100644
--- a/actionpack/test/controller/request_test.rb
+++ b/actionpack/test/controller/request_test.rb
@@ -274,7 +274,7 @@ class RequestTest < Test::Unit::TestCase
end
def test_symbolized_request_methods
- [:head, :get, :post, :put, :delete].each do |method|
+ [:get, :post, :put, :delete].each do |method|
set_request_method_to method
assert_equal method, @request.method
end
@@ -282,7 +282,7 @@ class RequestTest < Test::Unit::TestCase
def test_allow_method_hacking_on_post
set_request_method_to :post
- [:head, :get, :put, :delete].each do |method|
+ [:get, :put, :delete].each do |method|
@request.instance_eval { @parameters = { :_method => method } ; @request_method = nil }
assert_equal method, @request.method
end
@@ -290,11 +290,18 @@ class RequestTest < Test::Unit::TestCase
def test_restrict_method_hacking
@request.instance_eval { @parameters = { :_method => 'put' } }
- [:head, :get, :put, :delete].each do |method|
+ [:get, :put, :delete].each do |method|
set_request_method_to method
assert_equal method, @request.method
end
end
+
+ def test_head_masquarading_as_get
+ set_request_method_to :head
+ assert_equal :get, @request.method
+ assert @request.get?
+ assert @request.head?
+ end
protected
def set_request_method_to(method)