diff --git a/app/models/theme.rb b/app/models/theme.rb index b0887074016..0f57ae5e537 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -155,7 +155,7 @@ class Theme < ActiveRecord::Base SvgSprite.expire_cache end - BASE_COMPILER_VERSION = 54 + BASE_COMPILER_VERSION = 55 def self.compiler_version get_set_cache "compiler_version" do dependencies = [ @@ -563,10 +563,10 @@ class Theme < ActiveRecord::Base hash = {} Theme.where(id: Theme.transform_ids(id)).each do |theme| - hash.merge!(theme.cached_settings) + hash.merge!(theme.build_settings_hash) end - hash.merge!(self.cached_settings) + hash.merge!(self.build_settings_hash) hash end diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb index 6fbe8d14b6a..04f2a441a26 100644 --- a/spec/models/theme_spec.rb +++ b/spec/models/theme_spec.rb @@ -341,6 +341,18 @@ HTML expect(scss).to include('font-size:"#{$fakeinterpolatedvariable}\a andanothervalue \'withquotes\'; margin: 0;\a"') end + it "can use a setting straight away after introducing it" do + theme.set_field(target: :common, name: :scss, value: 'body {background-color: red;}') + theme.save! + + theme.reload + theme.set_field(target: :settings, name: :yaml, value: "background_color: red\nfont_size: 25px") + theme.set_field(target: :common, name: :scss, value: 'body {background-color: $background_color;}') + theme.save! + + expect(theme.theme_fields.find_by(target_id: Theme.targets[:common], name: "scss").error).to eq(nil) + end + it "allows values to be used in JS" do theme.name = 'awesome theme"' theme.set_field(target: :settings, name: :yaml, value: "name: bob") @@ -440,6 +452,10 @@ HTML end def cached_settings(id) + Theme.find_by(id: id).cached_settings.to_json + end + + def included_settings(id) Theme.find_by(id: id).included_settings.to_json end @@ -549,32 +565,32 @@ HTML expect(json["my_upload"]).to eq("http://cdn.localhost#{upload.url}") end - it 'handles settings cache correctly' do + it 'handles child settings correctly' do Theme.destroy_all - expect(cached_settings(theme.id)).to eq("{}") + expect(included_settings(theme.id)).to eq("{}") theme.set_field(target: :settings, name: "yaml", value: "boolean_setting: true") theme.save! - expect(cached_settings(theme.id)).to match(/\"boolean_setting\":true/) + expect(included_settings(theme.id)).to match(/\"boolean_setting\":true/) theme.settings.first.value = "false" theme.save! - expect(cached_settings(theme.id)).to match(/\"boolean_setting\":false/) + expect(included_settings(theme.id)).to match(/\"boolean_setting\":false/) child.set_field(target: :settings, name: "yaml", value: "integer_setting: 54") child.save! theme.add_relative_theme!(:child, child) - json = cached_settings(theme.id) + json = included_settings(theme.id) expect(json).to match(/\"boolean_setting\":false/) expect(json).to match(/\"integer_setting\":54/) - expect(cached_settings(child.id)).to eq("{\"integer_setting\":54}") + expect(included_settings(child.id)).to eq("{\"integer_setting\":54}") child.destroy! - json = cached_settings(theme.id) + json = included_settings(theme.id) expect(json).not_to match(/\"integer_setting\":54/) expect(json).to match(/\"boolean_setting\":false/) end