diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-11-29 02:08:51 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-11-29 02:08:51 +0000 |
commit | 0a9bc591e78382b221ef5c2f463bac90564b9982 (patch) | |
tree | fb4a264ddb46ba16fd04327f6ca27da1aa1a5569 /actionpack/test/controller | |
parent | ab73a988aca073e6ff16cd608df6e2e08808d31c (diff) | |
download | rails-0a9bc591e78382b221ef5c2f463bac90564b9982.tar.gz rails-0a9bc591e78382b221ef5c2f463bac90564b9982.tar.bz2 rails-0a9bc591e78382b221ef5c2f463bac90564b9982.zip |
Raise UnknownHttpMethod exception for unknown HTTP methods. Closes #10303 [tarmo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8235 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/request_test.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 1ade378739..1ae1f975a0 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -306,11 +306,26 @@ class RequestTest < Test::Unit::TestCase end end + def test_invalid_http_method_raises_exception + set_request_method_to :random_method + assert_raises(ActionController::UnknownHttpMethod) do + @request.method + end + end + def test_allow_method_hacking_on_post set_request_method_to :post - [:get, :put, :delete].each do |method| + [:get, :head, :put, :post, :delete].each do |method| @request.instance_eval { @parameters = { :_method => method } ; @request_method = nil } - assert_equal method, @request.method + assert_equal(method == :head ? :get : method, @request.method) + end + end + + def test_invalid_method_hacking_on_post_raises_exception + set_request_method_to :post + @request.instance_eval { @parameters = { :_method => :random_method } ; @request_method = nil } + assert_raises(ActionController::UnknownHttpMethod) do + @request.method end end |