httpx/regression_tests/bug_0_14_2_test.rb
HoneyryderChuck 3f73d2e3ce multipart supported by default
the plugin was now moved to the transcoder layer, where it is available
from the get-go.
2023-09-20 17:57:41 +01:00

32 lines
868 B
Ruby

# frozen_string_literal: true
require "test_helper"
require "support/http_helpers"
class Bug_0_14_2_Test < Minitest::Test
include HTTPHelpers
def test_multipart_can_have_arbitrary_filename
uri = "https://#{httpbin}/post"
response = HTTPX.post(uri, form: {
image: {
filename: "weird-al-jankovic",
body: File.new(fixture_file_path),
},
})
verify_status(response, 200)
body = json_body(response)
verify_header(body["headers"], "Content-Type", "multipart/form-data")
# can't really test the filename, but if it's in the files field,
# then it was a file upload
verify_uploaded_image(body, "image", "image/jpeg")
end
private
def origin(orig = httpbin)
"http://#{orig}"
end
end