From 98bb99ef61902c1073cc51a52ab7954c0ca922a5 Mon Sep 17 00:00:00 2001 From: claudiob Date: Tue, 1 Aug 2017 10:56:39 -0700 Subject: Don't depend on HTTParty "httparty" is only added in #30020 to write two tests to make PUT requests against S3 and GCS. The same requests can be made with net/http, removing a dependency from the Gemfile. --- activestorage/test/service/azure_service_test.rb | 1 - activestorage/test/service/gcs_service_test.rb | 16 +++++++++------- activestorage/test/service/s3_service_test.rb | 16 +++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'activestorage') diff --git a/activestorage/test/service/azure_service_test.rb b/activestorage/test/service/azure_service_test.rb index 0ddbac83e7..fb617db019 100644 --- a/activestorage/test/service/azure_service_test.rb +++ b/activestorage/test/service/azure_service_test.rb @@ -1,5 +1,4 @@ require "service/shared_service_tests" -require "httparty" require "uri" if SERVICE_CONFIGURATIONS[:azure] diff --git a/activestorage/test/service/gcs_service_test.rb b/activestorage/test/service/gcs_service_test.rb index 134a06e3a4..aca779c167 100644 --- a/activestorage/test/service/gcs_service_test.rb +++ b/activestorage/test/service/gcs_service_test.rb @@ -1,5 +1,5 @@ require "service/shared_service_tests" -require "httparty" +require "net/http" if SERVICE_CONFIGURATIONS[:gcs] class ActiveStorage::Service::GCSServiceTest < ActiveSupport::TestCase @@ -14,12 +14,14 @@ if SERVICE_CONFIGURATIONS[:gcs] checksum = Digest::MD5.base64digest(data) url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size, checksum: checksum) - HTTParty.put( - url, - body: data, - headers: { "Content-Type" => "text/plain", "Content-MD5" => checksum }, - debug_output: STDOUT - ) + uri = URI.parse url + request = Net::HTTP::Put.new uri.request_uri + request.body = data + request.add_field 'Content-Type', 'text/plain' + request.add_field 'Content-MD5', checksum + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + http.request request + end assert_equal data, @service.download(key) ensure diff --git a/activestorage/test/service/s3_service_test.rb b/activestorage/test/service/s3_service_test.rb index fa2df263a6..a8bec0736d 100644 --- a/activestorage/test/service/s3_service_test.rb +++ b/activestorage/test/service/s3_service_test.rb @@ -1,5 +1,5 @@ require "service/shared_service_tests" -require "httparty" +require "net/http" if SERVICE_CONFIGURATIONS[:s3] class ActiveStorage::Service::S3ServiceTest < ActiveSupport::TestCase @@ -14,12 +14,14 @@ if SERVICE_CONFIGURATIONS[:s3] checksum = Digest::MD5.base64digest(data) url = @service.url_for_direct_upload(key, expires_in: 5.minutes, content_type: "text/plain", content_length: data.size, checksum: checksum) - HTTParty.put( - url, - body: data, - headers: { "Content-Type" => "text/plain", "Content-MD5" => checksum }, - debug_output: STDOUT - ) + uri = URI.parse url + request = Net::HTTP::Put.new uri.request_uri + request.body = data + request.add_field 'Content-Type', 'text/plain' + request.add_field 'Content-MD5', checksum + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + http.request request + end assert_equal data, @service.download(key) ensure -- cgit v1.2.3