Sha256: 0d94afc3542734bd045994d47854a9032964ae2790dec5ae53e6792a4a80811b

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

if Rack.release < '1.6'
  warn "Rack #{Rack.release} used, skipping disallow_file_uploads plugin test"  
else
describe "disallow_file_uploads plugin" do 
  it "disallows the uploading of files" do
    app do |r|
      r['foo'][:tempfile].read
    end

    request_body = StringIO.new("------WebKitFormBoundarymwHIM9XjTTVHn3YP\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"bar.txt\"\r\nContent-Type: text/plain\r\n\r\nfoo\n\r\n------WebKitFormBoundarymwHIM9XjTTVHn3YP--\r\n")

    h = {
      'rack.input'=>request_body,
      'CONTENT_TYPE'=>'multipart/form-data; boundary=----WebKitFormBoundarymwHIM9XjTTVHn3YP',
      'CONTENT_LENGTH'=>'184',
      'REQUEST_METHOD'=>'POST'
    }
    body(h.dup).must_equal "foo\n"
    app.plugin :disallow_file_uploads
    proc{body(h.dup)}.must_raise Roda::RodaPlugins::DisallowFileUploads::Error
  end
end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roda-2.29.0 spec/plugin/disallow_file_uploads_spec.rb
roda-2.28.0 spec/plugin/disallow_file_uploads_spec.rb
roda-2.27.0 spec/plugin/disallow_file_uploads_spec.rb
roda-2.26.0 spec/plugin/disallow_file_uploads_spec.rb
roda-2.25.0 spec/plugin/disallow_file_uploads_spec.rb
roda-2.24.0 spec/plugin/disallow_file_uploads_spec.rb