mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
feab7031b5
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`.
19 lines
639 B
Ruby
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
|