FIX: changing component settings should trigger refresh for parent theme CSS (#6340)

This commit is contained in:
Osama Sayegh 2018-08-30 13:53:03 +03:00 committed by Sam
parent 3ed9533066
commit 9efbf2c49f
2 changed files with 25 additions and 3 deletions

View File

@ -302,13 +302,16 @@ class Stylesheet::Manager
end
def 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)

View File

@ -65,7 +65,6 @@ describe Stylesheet::Manager do
end
it '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 do
expect(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") }