aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/request_test.rb19
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