Permalink
Browse files

Merge pull request #588 from statianzo/tempfile-form-input

Use equal? to compare form_input to rack.input
  • Loading branch information...
2 parents 53e927c + b059307 commit bbae0ce30ddeb9f8a2a208d08e479ee5a85a1a02 @spastorino spastorino committed Aug 22, 2013
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/rack/request.rb
  2. +15 −0 test/spec_request.rb
View
@@ -204,7 +204,7 @@ def GET
def POST
if @env["rack.input"].nil?
raise "Missing rack.input"
- elsif @env["rack.request.form_input"].eql? @env["rack.input"]
+ elsif @env["rack.request.form_input"].equal? @env["rack.input"]
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
unless @env["rack.request.form_hash"] = parse_multipart(env)
View
@@ -878,6 +878,21 @@
lambda{ req.POST }.should.not.raise("input re-processed!")
end
+ should "use form_hash when form_input is a Tempfile" do
+ input = "{foo: 'bar'}"
+
+ rack_input = Tempfile.new("rackspec")
+ rack_input.write(input)
+ rack_input.rewind
+
+ req = Rack::Request.new Rack::MockRequest.env_for("/",
+ "rack.request.form_hash" => {'foo' => 'bar'},
+ "rack.request.form_input" => rack_input,
+ :input => rack_input)
+
+ req.POST.should.equal(req.env['rack.request.form_hash'])
+ end
+
should "conform to the Rack spec" do
app = lambda { |env|
content = Rack::Request.new(env).POST["file"].inspect

0 comments on commit bbae0ce

Please sign in to comment.