mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: Allow unbaked theme fields to be destroyed
The after_commit hook was attempting to re-bake theme_fields after they were destroyed, which caused an exception to be thrown
This commit is contained in:
parent
9eb7dea0f1
commit
91f0468f4e
@ -372,7 +372,7 @@ class ThemeField < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
after_commit do
|
||||
after_commit on: [:create, :update] do
|
||||
ensure_baked!
|
||||
ensure_scss_compiles!
|
||||
theme.clear_cached_settings!
|
||||
|
@ -127,6 +127,25 @@ HTML
|
||||
expect(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' do
|
||||
theme.set_field(target: :common, name: :body_tag, value: "<b>test")
|
||||
theme.save
|
||||
|
Loading…
Reference in New Issue
Block a user