1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test URL generation for S3 and Disk

This commit is contained in:
David Heinemeier Hansson 2017-07-09 17:04:37 +02:00
parent 4bfe7af68f
commit 5bb3f63b31
2 changed files with 10 additions and 0 deletions

View file

@ -5,4 +5,9 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
SERVICE = ActiveStorage::Service::DiskService.new(root: File.join(Dir.tmpdir, "active_storage"))
include ActiveStorage::Service::SharedServiceTests
test "url generation" do
assert_match /rails\/blobs\/.*\/avatar\.png\?disposition=inline/,
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
end
end

View file

@ -5,6 +5,11 @@ if SERVICE_CONFIGURATIONS[:s3]
SERVICE = ActiveStorage::Service.configure(:s3, SERVICE_CONFIGURATIONS)
include ActiveStorage::Service::SharedServiceTests
test "signed URL generation" do
assert_match /rails-activestorage\.s3\.amazonaws\.com.*response-content-disposition=inline.*avatar\.png/,
@service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: :inline, filename: "avatar.png")
end
end
else
puts "Skipping S3 Service tests because no S3 configuration was supplied"