From e119c6e01e77cef972fe474b0d4254876093442f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 20 Apr 2017 10:31:23 -0400 Subject: [PATCH] FIX: embedded comments not working when theme is missing --- lib/stylesheet/manager.rb | 10 +++++++--- spec/components/stylesheet/manager_spec.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb index 59b078e58b2..e84a0ed0e83 100644 --- a/lib/stylesheet/manager.rb +++ b/lib/stylesheet/manager.rb @@ -41,10 +41,14 @@ class Stylesheet::Manager @lock.synchronize do builder = self.new(target, theme_key) - builder.compile unless File.exists?(builder.stylesheet_fullpath) - tag = %[] - cache[cache_key] = tag + if builder.is_theme? && !builder.theme + tag = "" + else + builder.compile unless File.exists?(builder.stylesheet_fullpath) + tag = %[] + end + cache[cache_key] = tag tag.dup.html_safe end end diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rb index 3098e6000c7..8634216cc3e 100644 --- a/spec/components/stylesheet/manager_spec.rb +++ b/spec/components/stylesheet/manager_spec.rb @@ -2,6 +2,18 @@ require 'rails_helper' require 'stylesheet/compiler' describe Stylesheet::Manager do + + it 'does not crash for missing theme' do + link = Stylesheet::Manager.stylesheet_link_tag(:embedded_theme) + expect(link).to eq("") + + theme = Theme.create(name: "embedded", user_id: -1) + SiteSetting.default_theme_key = theme.key + + link = Stylesheet::Manager.stylesheet_link_tag(:embedded_theme) + expect(link).not_to eq("") + end + it 'can correctly compile theme css' do theme = Theme.new( name: 'parent',