diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-07-16 05:01:29 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-16 05:02:29 +0100 |
commit | 1d002f6bcbd4e4f5cc421ee4da5be18839ccc4cb (patch) | |
tree | 680aa610972ab5dfa7ace1e6885a3dfdb5c105d1 /actionpack/test | |
parent | fea5b6fd41f7d667fe637c9e9e31b51489ee5a50 (diff) | |
download | rails-1d002f6bcbd4e4f5cc421ee4da5be18839ccc4cb.tar.gz rails-1d002f6bcbd4e4f5cc421ee4da5be18839ccc4cb.tar.bz2 rails-1d002f6bcbd4e4f5cc421ee4da5be18839ccc4cb.zip |
Make RackRequest#request_method respect _method
Diffstat (limited to 'actionpack/test')
-rwxr-xr-x | actionpack/test/controller/cgi_test.rb | 33 | ||||
-rw-r--r-- | actionpack/test/controller/rack_test.rb | 33 |
2 files changed, 66 insertions, 0 deletions
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index 7367036dec..9120458d24 100755 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -53,6 +53,14 @@ class BaseCgiTest < Test::Unit::TestCase end def default_test; end + + private + + def set_content_data(data) + @request.env['CONTENT_LENGTH'] = data.length + @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' + @request.env['RAW_POST_DATA'] = data + end end class CgiRequestTest < BaseCgiTest @@ -180,6 +188,31 @@ class CgiRequestContentTypeTest < BaseCgiTest end end +class CgiRequestMethodTest < BaseCgiTest + def test_get + assert_equal :get, @request.request_method + end + + def test_post + @request.env['REQUEST_METHOD'] = 'POST' + assert_equal :post, @request.request_method + end + + def test_put + @request.env['REQUEST_METHOD'] = 'POST' + set_content_data '_method=put' + + assert_equal :put, @request.request_method + end + + def test_delete + @request.env['REQUEST_METHOD'] = 'POST' + set_content_data '_method=delete' + + assert_equal :delete, @request.request_method + end +end + class CgiRequestNeedsRewoundTest < BaseCgiTest def test_body_should_be_rewound data = 'foo' diff --git a/actionpack/test/controller/rack_test.rb b/actionpack/test/controller/rack_test.rb index 1cef1e0f58..99edb2c901 100644 --- a/actionpack/test/controller/rack_test.rb +++ b/actionpack/test/controller/rack_test.rb @@ -51,6 +51,14 @@ class BaseRackTest < Test::Unit::TestCase end def default_test; end + + private + + def set_content_data(data) + @request.env['CONTENT_LENGTH'] = data.length + @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' + @request.env['RAW_POST_DATA'] = data + end end class RackRequestTest < BaseRackTest @@ -178,6 +186,31 @@ class RackRequestContentTypeTest < BaseRackTest end end +class RackRequestMethodTest < BaseRackTest + def test_get + assert_equal :get, @request.request_method + end + + def test_post + @request.env['REQUEST_METHOD'] = 'POST' + assert_equal :post, @request.request_method + end + + def test_put + @request.env['REQUEST_METHOD'] = 'POST' + set_content_data '_method=put' + + assert_equal :put, @request.request_method + end + + def test_delete + @request.env['REQUEST_METHOD'] = 'POST' + set_content_data '_method=delete' + + assert_equal :delete, @request.request_method + end +end + class RackRequestNeedsRewoundTest < BaseRackTest def test_body_should_be_rewound data = 'foo' |