mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #36642 from wagenet/fix-disk-service-host
Fix host for ActiveStorage DiskService
This commit is contained in:
commit
fc175375e1
2 changed files with 13 additions and 3 deletions
|
@ -84,8 +84,12 @@ module ActiveStorage
|
|||
purpose: :blob_key }
|
||||
)
|
||||
|
||||
current_uri = URI.parse(current_host)
|
||||
|
||||
generated_url = url_helpers.rails_disk_service_url(verified_key_with_expiration,
|
||||
host: current_host,
|
||||
protocol: current_uri.scheme,
|
||||
host: current_uri.host,
|
||||
port: current_uri.port,
|
||||
disposition: content_disposition,
|
||||
content_type: content_type,
|
||||
filename: filename
|
||||
|
|
|
@ -8,8 +8,14 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
|
|||
include ActiveStorage::Service::SharedServiceTests
|
||||
|
||||
test "URL generation" do
|
||||
assert_match(/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png\?content_type=image%2Fpng&disposition=inline/,
|
||||
@service.url(@key, expires_in: 5.minutes, disposition: :inline, filename: ActiveStorage::Filename.new("avatar.png"), content_type: "image/png"))
|
||||
original_url_options = Rails.application.routes.default_url_options.dup
|
||||
Rails.application.routes.default_url_options.merge!(protocol: "http", host: "test.example.com", port: 3001)
|
||||
begin
|
||||
assert_match(/^https:\/\/example.com\/rails\/active_storage\/disk\/.*\/avatar\.png\?content_type=image%2Fpng&disposition=inline/,
|
||||
@service.url(@key, expires_in: 5.minutes, disposition: :inline, filename: ActiveStorage::Filename.new("avatar.png"), content_type: "image/png"))
|
||||
ensure
|
||||
Rails.application.routes.default_url_options = original_url_options
|
||||
end
|
||||
end
|
||||
|
||||
test "headers_for_direct_upload generation" do
|
||||
|
|
Loading…
Reference in a new issue