diff options
author | claudiob <claudiob@users.noreply.github.com> | 2017-08-01 10:56:39 -0700 |
---|---|---|
committer | claudiob <claudiob@users.noreply.github.com> | 2017-08-01 10:56:39 -0700 |
commit | 98bb99ef61902c1073cc51a52ab7954c0ca922a5 (patch) | |
tree | c334d87dfc3321aa248eb4d3b8e2dbd9ff7edfd2 /activestorage | |
parent | a9cb1968b6a01572a472a3df3aa750ebc022e076 (diff) | |
download | rails-98bb99ef61902c1073cc51a52ab7954c0ca922a5.tar.gz rails-98bb99ef61902c1073cc51a52ab7954c0ca922a5.tar.bz2 rails-98bb99ef61902c1073cc51a52ab7954c0ca922a5.zip |
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.
Diffstat (limited to 'activestorage')
-rw-r--r-- | activestorage/test/service/azure_service_test.rb | 1 | ||||
-rw-r--r-- | activestorage/test/service/gcs_service_test.rb | 16 | ||||
-rw-r--r-- | activestorage/test/service/s3_service_test.rb | 16 |
3 files changed, 18 insertions, 15 deletions
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 |