FIX: theme CSS should recompile when theme uploads change
This commit is contained in:
parent
c34100d1e7
commit
2427c0a17c
|
@ -256,7 +256,7 @@ class Stylesheet::Manager
|
||||||
raise "attempting to look up theme digest for invalid field"
|
raise "attempting to look up theme digest for invalid field"
|
||||||
end
|
end
|
||||||
|
|
||||||
Digest::SHA1.hexdigest(scss.to_s + color_scheme_digest.to_s + settings_digest + plugins_digest)
|
Digest::SHA1.hexdigest(scss.to_s + color_scheme_digest.to_s + settings_digest + plugins_digest + uploads_digest)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this protects us from situations where new versions of a plugin removed a file
|
# this protects us from situations where new versions of a plugin removed a file
|
||||||
|
@ -274,6 +274,10 @@ class Stylesheet::Manager
|
||||||
Digest::SHA1.hexdigest((theme&.included_settings || {}).to_json)
|
Digest::SHA1.hexdigest((theme&.included_settings || {}).to_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def uploads_digest
|
||||||
|
Digest::SHA1.hexdigest(ThemeField.joins(:upload).where(id: theme&.all_theme_variables).pluck(:sha1).join(","))
|
||||||
|
end
|
||||||
|
|
||||||
def color_scheme_digest
|
def color_scheme_digest
|
||||||
|
|
||||||
cs = theme&.color_scheme
|
cs = theme&.color_scheme
|
||||||
|
|
|
@ -87,6 +87,45 @@ describe Stylesheet::Manager do
|
||||||
|
|
||||||
expect(digest1).not_to eq(digest2)
|
expect(digest1).not_to eq(digest2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:image) { file_from_fixtures("logo.png") }
|
||||||
|
let(:image2) { file_from_fixtures("logo-dev.png") }
|
||||||
|
|
||||||
|
it 'can correctly account for theme uploads in digest' do
|
||||||
|
theme = Theme.create!(
|
||||||
|
name: 'parent',
|
||||||
|
user_id: -1
|
||||||
|
)
|
||||||
|
|
||||||
|
upload = UploadCreator.new(image, "logo.png").create_for(-1)
|
||||||
|
field = ThemeField.create!(
|
||||||
|
theme_id: theme.id,
|
||||||
|
target_id: Theme.targets[:common],
|
||||||
|
name: "logo",
|
||||||
|
value: "",
|
||||||
|
upload_id: upload.id,
|
||||||
|
type_id: ThemeField.types[:theme_upload_var]
|
||||||
|
)
|
||||||
|
|
||||||
|
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||||
|
digest1 = manager.digest
|
||||||
|
field.destroy!
|
||||||
|
|
||||||
|
upload = UploadCreator.new(image2, "logo.png").create_for(-1)
|
||||||
|
field = ThemeField.create!(
|
||||||
|
theme_id: theme.id,
|
||||||
|
target_id: Theme.targets[:common],
|
||||||
|
name: "logo",
|
||||||
|
value: "",
|
||||||
|
upload_id: upload.id,
|
||||||
|
type_id: ThemeField.types[:theme_upload_var]
|
||||||
|
)
|
||||||
|
|
||||||
|
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||||
|
digest2 = manager.digest
|
||||||
|
|
||||||
|
expect(digest1).not_to eq(digest2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'color_scheme_digest' do
|
describe 'color_scheme_digest' do
|
||||||
|
|
Loading…
Reference in New Issue