FIX: Rebake theme fields if upload changes (#11341)

Updating SVG sprites of a theme did not take effect immediately because
the cache was not cleared.
This commit is contained in:
Bianca Nenciu 2020-11-25 01:49:12 +02:00 committed by GitHub
parent e527741577
commit f9ff51870b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -483,7 +483,7 @@ class ThemeField < ActiveRecord::Base
end
before_save do
if will_save_change_to_value? && !will_save_change_to_value_baked?
if (will_save_change_to_value? || will_save_change_to_upload_id?) && !will_save_change_to_value_baked?
self.value_baked = nil
end
end

View File

@ -419,4 +419,15 @@ HTML
end
end
context "SVG sprite theme fields" do
let(:upload) { Fabricate(:upload) }
let(:theme) { Fabricate(:theme) }
let(:theme_field) { ThemeField.create!(theme: theme, target_id: 0, name: SvgSprite.theme_sprite_variable_name, upload: upload, value: "", value_baked: "baked", type_id: ThemeField.types[:theme_upload_var]) }
it "is rebaked when upload changes" do
theme_field.update(upload: Fabricate(:upload))
expect(theme_field.value_baked).to eq(nil)
end
end
end