FIX: clear color scheme cache when clearing theme cache

This commit is contained in:
Sam 2018-10-16 12:00:33 +11:00
parent 08c404e138
commit 19d7543004
2 changed files with 25 additions and 0 deletions

View File

@ -109,6 +109,7 @@ class Theme < ActiveRecord::Base
Site.clear_anon_cache!
clear_cache!
ApplicationSerializer.expire_cache_fragment!("user_themes")
ColorScheme.hex_cache.clear
end
def self.clear_default!

View File

@ -417,6 +417,30 @@ HTML
Theme.find_by(id: id).included_settings.to_json
end
it 'clears color scheme cache correctly' do
Theme.destroy_all
cs = Fabricate(:color_scheme, name: 'Fancy', color_scheme_colors: [
Fabricate(:color_scheme_color, name: 'header_primary', hex: 'F0F0F0'),
Fabricate(:color_scheme_color, name: 'header_background', hex: '1E1E1E'),
Fabricate(:color_scheme_color, name: 'tertiary', hex: '858585')
])
theme = Fabricate(:theme,
user_selectable: true,
user: Fabricate(:admin),
color_scheme_id: cs.id
)
theme.set_default!
expect(ColorScheme.hex_for_name('header_primary')).to eq('F0F0F0')
Theme.clear_default!
expect(ColorScheme.hex_for_name('header_primary')).to eq('333333')
end
it 'handles settings cache correctly' do
Theme.destroy_all