diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 17:50:31 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 17:50:31 -0500 |
commit | 5944850bc1259ca42381ce83d155ddd914b968c6 (patch) | |
tree | a8579cc18b2d412a978b02385f15a22c56dd3ac4 /test | |
parent | cb2f7d499466acd2a8c9b917262914e46b5bf104 (diff) | |
download | rails-5944850bc1259ca42381ce83d155ddd914b968c6.tar.gz rails-5944850bc1259ca42381ce83d155ddd914b968c6.tar.bz2 rails-5944850bc1259ca42381ce83d155ddd914b968c6.zip |
Tell service which content-type to use for the response
Diffstat (limited to 'test')
-rw-r--r-- | test/models/blob_test.rb | 2 | ||||
-rw-r--r-- | test/service/disk_service_test.rb | 2 | ||||
-rw-r--r-- | test/service/gcs_service_test.rb | 5 | ||||
-rw-r--r-- | test/service/mirror_service_test.rb | 4 | ||||
-rw-r--r-- | test/service/s3_service_test.rb | 4 |
5 files changed, 9 insertions, 8 deletions
diff --git a/test/models/blob_test.rb b/test/models/blob_test.rb index 8a3d0e8124..b6ba63b25e 100644 --- a/test/models/blob_test.rb +++ b/test/models/blob_test.rb @@ -35,6 +35,6 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase private def expected_url_for(blob, disposition: :inline) - "/rails/active_storage/disk/#{ActiveStorage.verifier.generate(blob.key, expires_in: 5.minutes, purpose: :blob_key)}/#{blob.filename}?disposition=#{disposition}" + "/rails/active_storage/disk/#{ActiveStorage.verifier.generate(blob.key, expires_in: 5.minutes, purpose: :blob_key)}/#{blob.filename}?disposition=#{disposition}&content_type=#{blob.content_type}" end end diff --git a/test/service/disk_service_test.rb b/test/service/disk_service_test.rb index e9a96003f1..1dae4a2f00 100644 --- a/test/service/disk_service_test.rb +++ b/test/service/disk_service_test.rb @@ -7,6 +7,6 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase test "url generation" do assert_match /rails\/active_storage\/disk\/.*\/avatar\.png\?disposition=inline/, - @service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png") + @service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png", content_type: "image/png") end end diff --git a/test/service/gcs_service_test.rb b/test/service/gcs_service_test.rb index 4cde4b9289..57fe4d4562 100644 --- a/test/service/gcs_service_test.rb +++ b/test/service/gcs_service_test.rb @@ -29,9 +29,10 @@ if SERVICE_CONFIGURATIONS[:gcs] test "signed URL generation" do freeze_time do url = SERVICE.bucket.signed_url(FIXTURE_KEY, expires: 120) + - "&response-content-disposition=inline%3B+filename%3D%22test.txt%22" + "&response-content-disposition=inline%3B+filename%3D%22test.txt%22" + + "&response-content-type=text%2Fplain" - assert_equal url, @service.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt") + assert_equal url, @service.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt", content_type: "text/plain") end end end diff --git a/test/service/mirror_service_test.rb b/test/service/mirror_service_test.rb index fd3d8125d6..129e11d06f 100644 --- a/test/service/mirror_service_test.rb +++ b/test/service/mirror_service_test.rb @@ -46,8 +46,8 @@ class ActiveStorage::Service::MirrorServiceTest < ActiveSupport::TestCase test "URL generation in primary service" do freeze_time do - assert_equal SERVICE.primary.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt"), - @service.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt") + assert_equal SERVICE.primary.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt", content_type: "text/plain"), + @service.url(FIXTURE_KEY, expires_in: 2.minutes, disposition: :inline, filename: "test.txt", content_type: "text/plain") end end diff --git a/test/service/s3_service_test.rb b/test/service/s3_service_test.rb index 049511497b..a6040ec1d5 100644 --- a/test/service/s3_service_test.rb +++ b/test/service/s3_service_test.rb @@ -27,8 +27,8 @@ if SERVICE_CONFIGURATIONS[:s3] end test "signed URL generation" do - assert_match /#{SERVICE_CONFIGURATIONS[:s3][:bucket]}\.s3.(\S+)?amazonaws.com.*response-content-disposition=inline.*avatar\.png/, - @service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png") + assert_match /#{SERVICE_CONFIGURATIONS[:s3][:bucket]}\.s3.(\S+)?amazonaws.com.*response-content-disposition=inline.*avatar\.png.*response-content-type=image%2Fpng/, + @service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png", content_type: "image/png") end test "uploading with server-side encryption" do |