aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/service/gcs_service_test.rb
diff options
context:
space:
mode:
authorclaudiob <claudiob@users.noreply.github.com>2017-08-01 10:56:39 -0700
committerclaudiob <claudiob@users.noreply.github.com>2017-08-01 10:56:39 -0700
commit98bb99ef61902c1073cc51a52ab7954c0ca922a5 (patch)
treec334d87dfc3321aa248eb4d3b8e2dbd9ff7edfd2 /activestorage/test/service/gcs_service_test.rb
parenta9cb1968b6a01572a472a3df3aa750ebc022e076 (diff)
downloadrails-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/test/service/gcs_service_test.rb')
-rw-r--r--activestorage/test/service/gcs_service_test.rb16
1 files changed, 9 insertions, 7 deletions
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