Skip to content

Commit

Permalink
Use RackRequest as a mock instead of StubCGI into RequestTest
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 18, 2008
1 parent 9660799 commit 894f9cc
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions actionpack/test/controller/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -509,7 +508,6 @@ def test_unbalanced_query_string_with_array
)
end


def test_request_hash_parsing
query = {
"note[viewers][viewer][][type]" => ["User", "Group"],
Expand All @@ -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" ],
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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

Expand All @@ -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.