A platform for community discussion. Free, open, simple.
FIX: changing component settings should trigger refresh for parent theme CSS (#6340)
Osama Sayegh9efbf2c49feb
diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rbindex 8279c3d3f70..3b4b4400a76 100644--- a/lib/stylesheet/manager.rb+++ b/lib/stylesheet/manager.rb@@ -302,13 +302,16 @@ class Stylesheet::Managerenddef settings_digest+ theme_ids = Theme.components_for(@theme_id).dup+ theme_ids << @theme_id+fields = ThemeField.where(name: "yaml",type_id: ThemeField.types[:yaml],- theme_id: @theme_id+ theme_id: theme_ids).pluck(:updated_at)- settings = ThemeSetting.where(theme_id: @theme_id).pluck(:updated_at)+ settings = ThemeSetting.where(theme_id: theme_ids).pluck(:updated_at)timestamps = fields.concat(settings).map!(&:to_f).sort!.join(",")Digest::SHA1.hexdigest(timestamps)diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex 541a4696bde..fb6f3fd5dbb 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -65,7 +65,6 @@ describe Stylesheet::Manager doendit 'can correctly account for plugins in digest' do-theme = Fabricate(:theme)manager = Stylesheet::Manager.new(:desktop_theme, theme.id)@@ -79,6 +78,26 @@ describe Stylesheet::Manager doexpect(digest1).not_to eq(digest2)end+ it "can correctly account for settings in theme's components" do+ theme = Fabricate(:theme)+ child = Fabricate(:theme, component: true)+ theme.add_child_theme!(child)++ child.set_field(target: :settings, name: :yaml, value: "childcolor: red")+ child.set_field(target: :common, name: :scss, value: "body {background-color: $childcolor}")+ child.save!++ manager = Stylesheet::Manager.new(:desktop_theme, theme.id)+ digest1 = manager.digest++ child.update_setting(:childcolor, "green")++ manager = Stylesheet::Manager.new(:desktop_theme, theme.id)+ digest2 = manager.digest++ expect(digest1).not_to eq(digest2)+ end+let(:image) { file_from_fixtures("logo.png") }let(:image2) { file_from_fixtures("logo-dev.png") }