FIX: Load base color scheme when default theme is not set

Followup to c937afc
This commit is contained in:
Penar Musaraj 2020-08-04 12:15:07 -04:00
parent 92b26ecbfb
commit 266c0c50d7
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
2 changed files with 7 additions and 1 deletions

View File

@ -97,7 +97,7 @@ class Stylesheet::Manager
color_scheme = begin color_scheme = begin
ColorScheme.find(color_scheme_id) ColorScheme.find(color_scheme_id)
rescue rescue
Theme.find(SiteSetting.default_theme_id).color_scheme || ColorScheme.base Theme.find_by_id(SiteSetting.default_theme_id)&.color_scheme || ColorScheme.base
end end
target = COLOR_SCHEME_STYLESHEET.to_sym target = COLOR_SCHEME_STYLESHEET.to_sym

View File

@ -171,6 +171,12 @@ describe Stylesheet::Manager do
expect(link).not_to eq("") expect(link).not_to eq("")
end end
it "does not crash when no default theme is set" do
SiteSetting.default_theme_id = -1
link = Stylesheet::Manager.color_scheme_stylesheet_link_tag()
expect(link).not_to eq("")
end
it "does not crash on missing color scheme" do it "does not crash on missing color scheme" do
link = Stylesheet::Manager.color_scheme_stylesheet_link_tag(125) link = Stylesheet::Manager.color_scheme_stylesheet_link_tag(125)
expect(link).not_to eq("") expect(link).not_to eq("")