FIX: return cdn url for uploads if available.
Currently it is displaying non-cdn urls in the composer preview.
This commit is contained in:
parent
8bc61e84a7
commit
f11363d446
|
@ -16,7 +16,7 @@ class UploadSerializer < ApplicationSerializer
|
|||
:human_filesize
|
||||
|
||||
def url
|
||||
return object.url if !object.secure || !SiteSetting.secure_media?
|
||||
return Discourse.store.cdn_url(object.url) if !object.secure || !SiteSetting.secure_media?
|
||||
UrlHelper.cook_url(object.url, secure: object.secure)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,6 +42,13 @@ describe UploadsController do
|
|||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns cdn url' do
|
||||
set_cdn_url "https://awesome.com"
|
||||
post "/uploads.json", params: { file: logo, type: "composer" }
|
||||
expect(response.status).to eq 200
|
||||
expect(response.parsed_body["url"]).to start_with("https://awesome.com/uploads/default/")
|
||||
end
|
||||
|
||||
it 'is successful with an attachment' do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
|
||||
|
|
Loading…
Reference in New Issue