Permalink
Browse files

Improve rack/cgi tests

  • Loading branch information...
1 parent 1d002f6 commit 2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5 @lifo lifo committed Jul 16, 2008
Showing with 6 additions and 12 deletions.
  1. +3 −6 actionpack/test/controller/cgi_test.rb
  2. +3 −6 actionpack/test/controller/rack_test.rb
View
9 actionpack/test/controller/cgi_test.rb
@@ -57,6 +57,7 @@ def default_test; end
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 @@ def test_cookie_syntax_resilience
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 @@ def test_post
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
View
9 actionpack/test/controller/rack_test.rb
@@ -55,6 +55,7 @@ def default_test; end
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 @@ def test_cookie_syntax_resilience
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 @@ def test_post
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

0 comments on commit 2a7aca8

Please sign in to comment.