1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/test/service/disk_public_service_test.rb
Peter Zhu feab7031b5 Permanent URLs for public storage blobs
Services can be configured in `config/storage.yml` with a new key
`public: true | false` to indicate whether a service holds public
blobs or private blobs. Public services will always return a
permanent URL.

Deprecates `Blob#service_url` in favor of `Blob#url`.
2019-10-11 15:14:43 -04:00

19 lines
639 B
Ruby

# frozen_string_literal: true
require "service/shared_service_tests"
require "net/http"
class ActiveStorage::Service::DiskPublicServiceTest < ActiveSupport::TestCase
tmp_config = {
tmp_public: { service: "Disk", root: File.join(Dir.tmpdir, "active_storage_public"), public: true }
}
SERVICE = ActiveStorage::Service.configure(:tmp_public, tmp_config)
include ActiveStorage::Service::SharedServiceTests
test "public URL generation" do
url = @service.url(@key, filename: ActiveStorage::Filename.new("avatar.png"))
assert_match(/^https:\/\/example.com\/rails\/active_storage\/disk\/public\/#{@key}/, url)
end
end