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`.
23 lines
734 B
Ruby
23 lines
734 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "service/shared_service_tests"
|
|
require "net/http"
|
|
|
|
if SERVICE_CONFIGURATIONS[:gcs_public]
|
|
class ActiveStorage::Service::GCSPublicServiceTest < ActiveSupport::TestCase
|
|
SERVICE = ActiveStorage::Service.configure(:gcs_public, SERVICE_CONFIGURATIONS)
|
|
|
|
include ActiveStorage::Service::SharedServiceTests
|
|
|
|
test "public URL generation" do
|
|
url = @service.url(@key, filename: ActiveStorage::Filename.new("avatar.png"))
|
|
|
|
assert_match(/storage\.googleapis\.com\/.*\/#{@key}/, url)
|
|
|
|
response = Net::HTTP.get_response(URI(url))
|
|
assert_equal "200", response.code
|
|
end
|
|
end
|
|
else
|
|
puts "Skipping GCS Public Service tests because no GCS configuration was supplied"
|
|
end
|