A platform for community discussion. Free, open, simple.
FIX: include both name and id in color scheme stylesheet filename slugs (#10397)
Penar Musarajf179510a68e2
diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rbindex 426a6702e20..7f7ab020dcd 100644--- a/lib/stylesheet/manager.rb+++ b/lib/stylesheet/manager.rb@@ -106,7 +106,7 @@ class Stylesheet::Managertarget = COLOR_SCHEME_STYLESHEET.to_symcurrent_hostname = Discourse.current_hostname- color_scheme_name = Slug.for(color_scheme.name)+ color_scheme_name = Slug.for(color_scheme.name) + color_scheme&.id.to_sarray_cache_key = "color_scheme_stylesheet_#{color_scheme_name}_#{current_hostname}"stylesheets = cache[array_cache_key]return stylesheets if stylesheets.present?@@ -300,7 +300,7 @@ class Stylesheet::Managerif is_theme?"#{@target}_#{theme.id}"elsif @color_scheme- "#{@target}_#{Slug.for(@color_scheme.name)}"+ "#{@target}_#{Slug.for(@color_scheme.name) + @color_scheme&.id.to_s}"elsescheme_string = theme && theme.color_scheme ? "_#{theme.color_scheme.id}" : """#{@target}#{scheme_string}"diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex efcdaa3dbaa..c74dce1d988 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -193,12 +193,13 @@ describe Stylesheet::Manager doSiteSetting.default_theme_id = theme.idlink = Stylesheet::Manager.color_scheme_stylesheet_link_tag()- expect(link).to include("/stylesheets/color_definitions_funky_")+ expect(link).to include("/stylesheets/color_definitions_funky#{cs.id}_")endit "uses the correct scheme when colors are passed" dolink = Stylesheet::Manager.color_scheme_stylesheet_link_tag(ColorScheme.first.id)- expect(link).to include("/stylesheets/color_definitions_#{Slug.for(ColorScheme.first.name)}_")+ slug = Slug.for(ColorScheme.first.name) + ColorScheme.first.id.to_s+ expect(link).to include("/stylesheets/color_definitions_#{slug}_")endit "does not fail with a color scheme name containing spaces and special characters" do@@ -207,7 +208,7 @@ describe Stylesheet::Manager doSiteSetting.default_theme_id = theme.idlink = Stylesheet::Manager.color_scheme_stylesheet_link_tag()- expect(link).to include("/stylesheets/color_definitions_funky-bunch_")+ expect(link).to include("/stylesheets/color_definitions_funky-bunch#{cs.id}_")endend