FIX: Clear stylesheet cache on base font change
Previously, we were not clearing the cache on themes using the default color scheme.
This commit is contained in:
parent
19b24e178c
commit
6610576deb
|
@ -27,7 +27,7 @@ DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
|||
end
|
||||
end
|
||||
|
||||
Stylesheet::Manager.clear_core_cache!(["desktop", "mobile", "admin"]) if name == :base_font
|
||||
Stylesheet::Manager.clear_core_cache!(["desktop", "mobile"]) if name == :base_font
|
||||
|
||||
Report.clear_cache(:storage_stats) if [:backup_location, :s3_backup_bucket].include?(name)
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ class Stylesheet::Manager
|
|||
theme_color_defs = theme&.resolve_baked_field(:common, :color_definitions)
|
||||
Digest::SHA1.hexdigest "#{RailsMultisite::ConnectionManagement.current_db}-#{cs&.id}-#{cs&.version}-#{theme_color_defs}-#{Stylesheet::Manager.last_file_updated}-#{category_updated}-#{SiteSetting.base_font}"
|
||||
else
|
||||
digest_string = "defaults-#{Stylesheet::Manager.last_file_updated}"
|
||||
digest_string = "defaults-#{Stylesheet::Manager.last_file_updated}-#{SiteSetting.base_font}"
|
||||
|
||||
if cdn_url = GlobalSetting.cdn_url
|
||||
digest_string = "#{digest_string}-#{cdn_url}"
|
||||
|
|
|
@ -143,8 +143,8 @@ describe Stylesheet::Manager do
|
|||
end
|
||||
|
||||
describe 'color_scheme_digest' do
|
||||
let(:theme) { Fabricate(:theme) }
|
||||
it "changes with category background image" do
|
||||
theme = Fabricate(:theme)
|
||||
category1 = Fabricate(:category, uploaded_background_id: 123, updated_at: 1.week.ago)
|
||||
category2 = Fabricate(:category, uploaded_background_id: 456, updated_at: 2.days.ago)
|
||||
|
||||
|
@ -178,7 +178,6 @@ describe Stylesheet::Manager do
|
|||
|
||||
it "updates digest when updating a theme's color definitions" do
|
||||
scheme = ColorScheme.base
|
||||
theme = Fabricate(:theme)
|
||||
manager = Stylesheet::Manager.new(:color_definitions, theme.id, scheme)
|
||||
digest1 = manager.color_scheme_digest
|
||||
|
||||
|
@ -190,6 +189,15 @@ describe Stylesheet::Manager do
|
|||
expect(digest1).to_not eq(digest2)
|
||||
end
|
||||
|
||||
it "updates digest when setting base font" do
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
digest1 = manager.color_scheme_digest
|
||||
SiteSetting.base_font = "nunito"
|
||||
digest2 = manager.color_scheme_digest
|
||||
|
||||
expect(digest1).to_not eq(digest2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'color_scheme_stylesheets' do
|
||||
|
|
Loading…
Reference in New Issue