Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve rack/cgi tests

  • Loading branch information...
commit 2a7aca8ec34ebfe0e30dd5e8696918b083ef56f5 1 parent 1d002f6
Pratik lifo authored
9 actionpack/test/controller/cgi_test.rb
View
@@ -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
9 actionpack/test/controller/rack_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.