FIX: Use CDN urls for theme uploads (#12769)

This commit is contained in:
Penar Musaraj 2021-04-20 13:25:35 -04:00 committed by GitHub
parent 0948c3725b
commit d44deb45f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -128,7 +128,7 @@ class Theme < ActiveRecord::Base
SvgSprite.expire_cache
end
BASE_COMPILER_VERSION = 48
BASE_COMPILER_VERSION = 49
def self.compiler_version
get_set_cache "compiler_version" do
dependencies = [
@ -493,7 +493,7 @@ class Theme < ActiveRecord::Base
theme_uploads = {}
upload_fields.each do |field|
theme_uploads[field.name] = field.upload.url
theme_uploads[field.name] = Discourse.store.cdn_url(field.upload.url)
end
hash['theme_uploads'] = theme_uploads if theme_uploads.present?

View File

@ -518,6 +518,19 @@ HTML
expect(json["theme_uploads"]["bob"]).to eq(upload.url)
end
it 'uses CDN url for theme_uploads in settings' do
set_cdn_url("http://cdn.localhost")
Theme.destroy_all
upload = UploadCreator.new(file_from_fixtures("logo.png"), "logo.png").create_for(-1)
theme.set_field(type: :theme_upload_var, target: :common, name: "bob", upload_id: upload.id)
theme.save!
json = JSON.parse(cached_settings(theme.id))
expect(json["theme_uploads"]["bob"]).to eq("http://cdn.localhost#{upload.url}")
end
it 'handles settings cache correctly' do
Theme.destroy_all