Permalink
Browse files

Use RackRequest as a mock instead of StubCGI into RequestTest

  • Loading branch information...
1 parent 9660799 commit 894f9ccc5354c29e102f316f388d1dc0b98ef080 @josh josh committed Aug 18, 2008
Showing with 10 additions and 14 deletions.
  1. +10 −14 actionpack/test/controller/request_test.rb
View
24 actionpack/test/controller/request_test.rb
@@ -397,7 +397,6 @@ def request_method=(method)
end
end
-
class UrlEncodedRequestParameterParsingTest < Test::Unit::TestCase
def setup
@query_string = "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1"
@@ -509,7 +508,6 @@ def test_unbalanced_query_string_with_array
)
end
-
def test_request_hash_parsing
query = {
"note[viewers][viewer][][type]" => ["User", "Group"],
@@ -521,7 +519,6 @@ def test_request_hash_parsing
assert_equal(expected, ActionController::AbstractRequest.parse_request_parameters(query))
end
-
def test_parse_params
input = {
"customers[boston][first][name]" => [ "David" ],
@@ -704,7 +701,6 @@ def test_parse_params_with_complex_nesting
end
end
-
class MultipartRequestParameterParsingTest < Test::Unit::TestCase
FIXTURE_PATH = File.dirname(__FILE__) + '/../fixtures/multipart'
@@ -852,20 +848,20 @@ def test_multiple_files
private
def parse_body(body)
- env = { 'CONTENT_TYPE' => 'application/xml',
+ env = { 'rack.input' => StringIO.new(body),
+ 'CONTENT_TYPE' => 'application/xml',
'CONTENT_LENGTH' => body.size.to_s }
- cgi = ActionController::Integration::Session::StubCGI.new(env, body)
- ActionController::CgiRequest.new(cgi).request_parameters
+ ActionController::RackRequest.new(env).request_parameters
end
end
class LegacyXmlParamsParsingTest < XmlParamsParsingTest
private
def parse_body(body)
- env = { 'HTTP_X_POST_DATA_FORMAT' => 'xml',
- 'CONTENT_LENGTH' => body.size.to_s }
- cgi = ActionController::Integration::Session::StubCGI.new(env, body)
- ActionController::CgiRequest.new(cgi).request_parameters
+ env = { 'rack.input' => StringIO.new(body),
+ 'HTTP_X_POST_DATA_FORMAT' => 'xml',
+ 'CONTENT_LENGTH' => body.size.to_s }
+ ActionController::RackRequest.new(env).request_parameters
end
end
@@ -884,9 +880,9 @@ def test_hash_params_for_application_jsonrequest
private
def parse_body(body,content_type)
- env = { 'CONTENT_TYPE' => content_type,
+ env = { 'rack.input' => StringIO.new(body),
+ 'CONTENT_TYPE' => content_type,
'CONTENT_LENGTH' => body.size.to_s }
- cgi = ActionController::Integration::Session::StubCGI.new(env, body)
- ActionController::CgiRequest.new(cgi).request_parameters
+ ActionController::RackRequest.new(env).request_parameters
end
end

0 comments on commit 894f9cc

Please sign in to comment.