aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/service
diff options
context:
space:
mode:
authorJeffrey Guenther <guenther.jeffrey@gmail.com>2017-12-08 13:25:54 -0800
committerJeffrey Guenther <guenther.jeffrey@gmail.com>2017-12-08 13:25:54 -0800
commita822287cefc38b9b8b3be38ffd775cd3d511b7c3 (patch)
treed69c6ea1fcc4299caa11bcbef2ce5520347a4f46 /activestorage/test/service
parent08fab27db52aa375df85a23e89799600f785b9d4 (diff)
parentda8e0ba03cbae33857954c0c1a228bd6dae562da (diff)
downloadrails-a822287cefc38b9b8b3be38ffd775cd3d511b7c3.tar.gz
rails-a822287cefc38b9b8b3be38ffd775cd3d511b7c3.tar.bz2
rails-a822287cefc38b9b8b3be38ffd775cd3d511b7c3.zip
Merge branch 'master' into activestorage-guide
Diffstat (limited to 'activestorage/test/service')
-rw-r--r--activestorage/test/service/gcs_service_test.rb14
-rw-r--r--activestorage/test/service/shared_service_tests.rb17
2 files changed, 31 insertions, 0 deletions
diff --git a/activestorage/test/service/gcs_service_test.rb b/activestorage/test/service/gcs_service_test.rb
index 1860149da9..7efcd60fb7 100644
--- a/activestorage/test/service/gcs_service_test.rb
+++ b/activestorage/test/service/gcs_service_test.rb
@@ -35,6 +35,20 @@ if SERVICE_CONFIGURATIONS[:gcs]
assert_match(/storage\.googleapis\.com\/.*response-content-disposition=inline.*test\.txt.*response-content-type=text%2Fplain/,
@service.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain"))
end
+
+ test "signed URL response headers" do
+ begin
+ key = SecureRandom.base58(24)
+ data = "Something else entirely!"
+ @service.upload(key, StringIO.new(data), checksum: Digest::MD5.base64digest(data))
+
+ url = @service.url(key, expires_in: 2.minutes, disposition: :inline, filename: ActiveStorage::Filename.new("test.txt"), content_type: "text/plain")
+ response = Net::HTTP.get_response(URI(url))
+ assert_equal "text/plain", response.header["Content-Type"]
+ ensure
+ @service.delete key
+ end
+ end
end
else
puts "Skipping GCS Service tests because no GCS configuration was supplied"
diff --git a/activestorage/test/service/shared_service_tests.rb b/activestorage/test/service/shared_service_tests.rb
index ade91ab89a..ce28c4393a 100644
--- a/activestorage/test/service/shared_service_tests.rb
+++ b/activestorage/test/service/shared_service_tests.rb
@@ -75,5 +75,22 @@ module ActiveStorage::Service::SharedServiceTests
@service.delete SecureRandom.base58(24)
end
end
+
+ test "deleting by prefix" do
+ begin
+ @service.upload("a/a/a", StringIO.new(FIXTURE_DATA))
+ @service.upload("a/a/b", StringIO.new(FIXTURE_DATA))
+ @service.upload("a/b/a", StringIO.new(FIXTURE_DATA))
+
+ @service.delete_prefixed("a/a/")
+ assert_not @service.exist?("a/a/a")
+ assert_not @service.exist?("a/a/b")
+ assert @service.exist?("a/b/a")
+ ensure
+ @service.delete("a/a/a")
+ @service.delete("a/a/b")
+ @service.delete("a/b/a")
+ end
+ end
end
end