A platform for community discussion. Free, open, simple.
FIX: Use CDN urls for theme uploads (#12769)
Penar Musarajd44deb45f344
diff --git a/app/models/theme.rb b/app/models/theme.rbindex 63ab1024822..c396c831f89 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -128,7 +128,7 @@ class Theme < ActiveRecord::BaseSvgSprite.expire_cacheend- BASE_COMPILER_VERSION = 48+ BASE_COMPILER_VERSION = 49def self.compiler_versionget_set_cache "compiler_version" dodependencies = [@@ -493,7 +493,7 @@ class Theme < ActiveRecord::Basetheme_uploads = {}upload_fields.each do |field|- theme_uploads[field.name] = field.upload.url+ theme_uploads[field.name] = Discourse.store.cdn_url(field.upload.url)endhash['theme_uploads'] = theme_uploads if theme_uploads.present?diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex 997bedb4be3..d9b5df23e26 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -518,6 +518,19 @@ HTMLexpect(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' doTheme.destroy_all