aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/dispatcher_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-02 01:20:36 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-02 01:20:36 +0000
commit1cfd25a7743b2a6f1e2e67a77c9ee3d949b9edb7 (patch)
treeb11d15e0433c901fe5d36e26d03a44394180767e /railties/test/dispatcher_test.rb
parentb4b47e560eb8627190fc6bcf3b54fd2faa62c5e2 (diff)
downloadrails-1cfd25a7743b2a6f1e2e67a77c9ee3d949b9edb7.tar.gz
rails-1cfd25a7743b2a6f1e2e67a77c9ee3d949b9edb7.tar.bz2
rails-1cfd25a7743b2a6f1e2e67a77c9ee3d949b9edb7.zip
Failsafe response handler for dispatcher.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2841 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test/dispatcher_test.rb')
-rw-r--r--railties/test/dispatcher_test.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/railties/test/dispatcher_test.rb b/railties/test/dispatcher_test.rb
index caf36fc9e9..bf5d235dfe 100644
--- a/railties/test/dispatcher_test.rb
+++ b/railties/test/dispatcher_test.rb
@@ -50,9 +50,46 @@ class DispatcherTest < Test::Unit::TestCase
assert_equal 0, ActionMailer::Base.subclasses.length
end
+
+ INVALID_MULTIPART = [
+ 'POST /foo HTTP/1.0',
+ 'Host: example.com',
+ 'Content-Type: multipart/form-data;boundary=foo'
+ ]
+
+ EMPTY_CONTENT = (INVALID_MULTIPART + [
+ 'Content-Length: 100',
+ nil, nil
+ ]).join("\r\n")
+
+ CONTENT_LENGTH_MISMATCH = (INVALID_MULTIPART + [
+ 'Content-Length: 100',
+ nil, nil,
+ 'foobar'
+ ]).join("\r\n")
+
+ NONINTEGER_CONTENT_LENGTH = (INVALID_MULTIPART + [
+ 'Content-Length: abc',
+ nil, nil
+ ]).join("\r\n")
+
+ def test_bad_multipart_request
+ old_stdin = $stdin
+ [EMPTY_CONTENT, CONTENT_LENGTH_MISMATCH, NONINTEGER_CONTENT_LENGTH].each do |bad_request|
+ $stdin = StringIO.new(bad_request)
+ output = StringIO.new
+ assert_nothing_raised do
+ Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output)
+ end
+ assert_equal "Status: 400 Bad Request\r\n", output.string
+ end
+ ensure
+ $stdin = old_stdin
+ end
+
private
def dispatch
- Dispatcher.dispatch(CGI.new, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output)
+ Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output)
end
def setup_minimal_environment