From bfa3e24e48ef7eb7d4c2c31e2f9d71e436e1f25c Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Mon, 1 Mar 2021 09:14:58 -0500 Subject: [PATCH] FIX: Update digest when updating color definitions in theme component (#12233) --- app/models/theme.rb | 2 +- spec/components/stylesheet/manager_spec.rb | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/models/theme.rb b/app/models/theme.rb index c6cabc17f77..e23bfbfd4cd 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -371,7 +371,7 @@ class Theme < ActiveRecord::Base end def list_baked_fields(target, name) - theme_ids = Theme.transform_ids([id], extend: false) + theme_ids = Theme.transform_ids([id], extend: name == :color_definitions) self.class.list_baked_fields(theme_ids, target, name) end diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rb index c8b6102c0cd..d4f935d4173 100644 --- a/spec/components/stylesheet/manager_spec.rb +++ b/spec/components/stylesheet/manager_spec.rb @@ -247,10 +247,30 @@ describe Stylesheet::Manager do theme.save! digest2 = manager.color_scheme_digest - expect(digest1).to_not eq(digest2) end + it "updates digest when updating a theme component's color definitions" do + scheme = ColorScheme.base + manager = Stylesheet::Manager.new(:color_definitions, theme.id, scheme) + digest1 = manager.color_scheme_digest + + child_theme = Fabricate(:theme, component: true) + child_theme.set_field(target: :common, name: "color_definitions", value: 'body {color: fuchsia}') + child_theme.save! + theme.add_relative_theme!(:child, child_theme) + theme.save! + + digest2 = manager.color_scheme_digest + expect(digest1).to_not eq(digest2) + + child_theme.set_field(target: :common, name: "color_definitions", value: 'body {color: blue}') + child_theme.save! + digest3 = manager.color_scheme_digest + expect(digest2).to_not eq(digest3) + + end + it "updates digest when setting fonts" do manager = Stylesheet::Manager.new(:desktop_theme, theme.id) digest1 = manager.color_scheme_digest