Skip to content

Commit

Permalink
We don't understand file uploads, yet
Browse files Browse the repository at this point in the history
  • Loading branch information
ahx committed Dec 30, 2022
1 parent 0aefde4 commit fc4893d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions spec/request_validation/request_body_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,15 @@
expect(last_response.status).to be 200
end

it 'succeeds with form data' do
it 'succeeds with simple multipart form data' do
header Rack::CONTENT_TYPE, 'multipart/form-data'
post '/with-form-data', request_body

expect(last_response.status).to be(200), last_response.body
expect(last_request.env[OpenapiFirst::REQUEST_BODY]).to eq request_body
end


it 'succeeds with form-urlencoded data' do
header Rack::CONTENT_TYPE, 'application/x-www-form-urlencoded'
post '/with-form-urlencoded', request_body
Expand All @@ -206,17 +207,7 @@
expect(last_request.env[OpenapiFirst::REQUEST_BODY]).to eq request_body
end

it "handles file upload" do
filename = "foo.txt"
file = File.expand_path("../../data/#{filename}", __FILE__)
post "/with-multipart-file", file: Rack::Test::UploadedFile.new(file, "text/plain")

expect(last_response.status).to be(200), last_response.body
# uploaded_file = env["router.params"].fetch(:file)

expect(uploaded_file.fetch(:filename)).to eq(filename)
expect(uploaded_file.fetch(:tempfile).read).to eq(contents)
end
it "handles file uploads"

it 'returns 415 if required request body is missing' do
header Rack::CONTENT_TYPE, 'application/json'
Expand Down

0 comments on commit fc4893d

Please sign in to comment.