diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-07-16 05:07:34 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-16 05:07:34 +0100 |
commit | 2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5 (patch) | |
tree | 660d909d9d9a0281ebc2ffed4c4232e7db0c1302 /actionpack/test/controller | |
parent | 1d002f6bcbd4e4f5cc421ee4da5be18839ccc4cb (diff) | |
download | rails-2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5.tar.gz rails-2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5.tar.bz2 rails-2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5.zip |
Improve rack/cgi tests
Diffstat (limited to 'actionpack/test/controller')
-rwxr-xr-x | actionpack/test/controller/cgi_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/controller/rack_test.rb | 9 |
2 files changed, 6 insertions, 12 deletions
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index 9120458d24..8ca70f8595 100755 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -57,6 +57,7 @@ class BaseCgiTest < Test::Unit::TestCase private def set_content_data(data) + @request.env['REQUEST_METHOD'] = 'POST' @request.env['CONTENT_LENGTH'] = data.length @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' @request.env['RAW_POST_DATA'] = data @@ -163,10 +164,8 @@ end class CgiRequestParamsParsingTest < BaseCgiTest def test_doesnt_break_when_content_type_has_charset - data = 'flamenco=love' - @request.env['CONTENT_LENGTH'] = data.length - @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - @request.env['RAW_POST_DATA'] = data + set_content_data 'flamenco=love' + assert_equal({"flamenco"=> "love"}, @request.request_parameters) end @@ -199,14 +198,12 @@ class CgiRequestMethodTest < BaseCgiTest 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 diff --git a/actionpack/test/controller/rack_test.rb b/actionpack/test/controller/rack_test.rb index 99edb2c901..ab8bbc3bf9 100644 --- a/actionpack/test/controller/rack_test.rb +++ b/actionpack/test/controller/rack_test.rb @@ -55,6 +55,7 @@ class BaseRackTest < Test::Unit::TestCase private def set_content_data(data) + @request.env['REQUEST_METHOD'] = 'POST' @request.env['CONTENT_LENGTH'] = data.length @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' @request.env['RAW_POST_DATA'] = data @@ -161,10 +162,8 @@ end class RackRequestParamsParsingTest < BaseRackTest def test_doesnt_break_when_content_type_has_charset - data = 'flamenco=love' - @request.env['CONTENT_LENGTH'] = data.length - @request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' - @request.env['RAW_POST_DATA'] = data + set_content_data 'flamenco=love' + assert_equal({"flamenco"=> "love"}, @request.request_parameters) end @@ -197,14 +196,12 @@ class RackRequestMethodTest < BaseRackTest 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 |