mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:50:26 -06:00
FIX: Use CDN urls for theme settings of type upload (#12773)
This commit is contained in:
parent
d51a226da4
commit
c47e6a2004
@ -128,7 +128,7 @@ class Theme < ActiveRecord::Base
|
||||
SvgSprite.expire_cache
|
||||
end
|
||||
|
||||
BASE_COMPILER_VERSION = 49
|
||||
BASE_COMPILER_VERSION = 50
|
||||
def self.compiler_version
|
||||
get_set_cache "compiler_version" do
|
||||
dependencies = [
|
||||
|
@ -173,5 +173,10 @@ class ThemeSettingsManager
|
||||
end
|
||||
|
||||
class Upload < self
|
||||
def value
|
||||
val = super
|
||||
Discourse.store.cdn_url(val)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -531,6 +531,24 @@ HTML
|
||||
expect(json["theme_uploads"]["bob"]).to eq("http://cdn.localhost#{upload.url}")
|
||||
end
|
||||
|
||||
it 'uses CDN url for settings of type upload' 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(target: :settings, name: "yaml", value: <<~YAML)
|
||||
my_upload:
|
||||
type: upload
|
||||
default: ""
|
||||
YAML
|
||||
|
||||
ThemeSetting.create!(theme: theme, data_type: ThemeSetting.types[:upload], value: upload.url, name: "my_upload")
|
||||
theme.save!
|
||||
|
||||
json = JSON.parse(cached_settings(theme.id))
|
||||
expect(json["my_upload"]).to eq("http://cdn.localhost#{upload.url}")
|
||||
end
|
||||
|
||||
it 'handles settings cache correctly' do
|
||||
Theme.destroy_all
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user