Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created June 8, 2011 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelStrother/28075f66b2a490431083 to your computer and use it in GitHub Desktop.
Save jdelStrother/28075f66b2a490431083 to your computer and use it in GitHub Desktop.
Failing test for rack's multipart handling with content types on multipart params
diff --git a/test/spec_utils.rb b/test/spec_utils.rb
index 822058b..636794d 100644
--- a/test/spec_utils.rb
+++ b/test/spec_utils.rb
@@ -614,4 +614,24 @@ describe Rack::Utils::Multipart do
should.raise(ArgumentError).
message.should.equal "value must be a Hash"
end
+
+ it "can parse fields with a content type" do
+ data = <<-EOF
+--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon\r
+Content-Disposition: form-data; name="description"\r
+Content-Type: text/plain"\r
+\r
+Very very blue\r
+--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon--\r
+EOF
+ options = {
+ "CONTENT_TYPE" => "multipart/form-data; boundary=1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon",
+ "CONTENT_LENGTH" => data.length.to_s,
+ :input => StringIO.new(data)
+ }
+ env = Rack::MockRequest.env_for("/", options)
+ params = Rack::Utils::Multipart.parse_multipart(env)
+
+ params.should.equal({"description"=>"Very very blue"})
+ end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment