A platform for community discussion. Free, open, simple.
FIX: Allow unbaked theme fields to be destroyed
David Taylor91f0468f4e7d
diff --git a/app/models/theme_field.rb b/app/models/theme_field.rbindex 7620129a005..53d44b8c7a1 100644--- a/app/models/theme_field.rb+++ b/app/models/theme_field.rb@@ -372,7 +372,7 @@ class ThemeField < ActiveRecord::Baseendend- after_commit do+ after_commit on: [:create, :update] doensure_baked!ensure_scss_compiles!theme.clear_cached_settings!diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex 17ba4f91271..a799ac0306b 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -127,6 +127,25 @@ HTMLexpect(field.javascript_cache.content).to include('raw-handlebars')end+ it 'can destroy unbaked theme without errors' do+ with_template = <<HTML+ <script type='text/x-handlebars' name='template'>+ {{hello}}+ </script>+ <script type='text/x-handlebars' data-template-name='raw_template.raw'>+ {{hello}}+ </script>+HTML+ theme.set_field(target: :common, name: "header", value: with_template)+ theme.save!++ field = theme.theme_fields.find_by(target_id: Theme.targets[:common], name: 'header')+ baked = Theme.lookup_field(theme.id, :mobile, "header")+ ThemeField.where(id: field.id).update_all(compiler_version: 0) # update_all to avoid callbacks++ field.reload.destroy!+ end+it 'should create body_tag_baked on demand if needed' dotheme.set_field(target: :common, name: :body_tag, value: "<b>test")theme.save