From 9e470b24c8869ac739a438132cdd5648bc6fe333 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 26 Aug 2017 23:15:14 +0900 Subject: [PATCH] Fix order of Active Storage DiskService URL parameters `content_type` parameter is before `disposition` parameter. --- activestorage/lib/active_storage/service/disk_service.rb | 2 +- activestorage/test/service/disk_service_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activestorage/lib/active_storage/service/disk_service.rb b/activestorage/lib/active_storage/service/disk_service.rb index 5aa8d74a5a..f600753a08 100644 --- a/activestorage/lib/active_storage/service/disk_service.rb +++ b/activestorage/lib/active_storage/service/disk_service.rb @@ -66,7 +66,7 @@ module ActiveStorage verified_key_with_expiration, filename: filename, disposition: disposition, content_type: content_type else - "/rails/active_storage/disk/#{verified_key_with_expiration}/#{filename}?disposition=#{disposition}&content_type=#{content_type}" + "/rails/active_storage/disk/#{verified_key_with_expiration}/#{filename}?content_type=#{content_type}&disposition=#{disposition}" end payload[:url] = generated_url diff --git a/activestorage/test/service/disk_service_test.rb b/activestorage/test/service/disk_service_test.rb index f57e44536a..e07d1d88bc 100644 --- a/activestorage/test/service/disk_service_test.rb +++ b/activestorage/test/service/disk_service_test.rb @@ -8,7 +8,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase include ActiveStorage::Service::SharedServiceTests test "url generation" do - assert_match(/rails\/active_storage\/disk\/.*\/avatar\.png\?.+disposition=inline/, + assert_match(/rails\/active_storage\/disk\/.*\/avatar\.png\?content_type=image%2Fpng&disposition=inline/, @service.url(FIXTURE_KEY, expires_in: 5.minutes, disposition: "inline; filename=\"avatar.png\"", filename: "avatar.png", content_type: "image/png")) end end