Navigation Menu

Skip to content

Commit

Permalink
FIX: include both name and id in color scheme stylesheet filename slu…
Browse files Browse the repository at this point in the history
…gs (#10397)
  • Loading branch information
pmusaraj committed Aug 7, 2020
1 parent 07dc5b5 commit f179510
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/stylesheet/manager.rb
Expand Up @@ -106,7 +106,7 @@ def self.color_scheme_stylesheet_details(color_scheme_id = nil, media)

target = COLOR_SCHEME_STYLESHEET.to_sym
current_hostname = Discourse.current_hostname
color_scheme_name = Slug.for(color_scheme.name)
color_scheme_name = Slug.for(color_scheme.name) + color_scheme&.id.to_s
array_cache_key = "color_scheme_stylesheet_#{color_scheme_name}_#{current_hostname}"
stylesheets = cache[array_cache_key]
return stylesheets if stylesheets.present?
Expand Down Expand Up @@ -300,7 +300,7 @@ def qualified_target
if 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}"
else
scheme_string = theme && theme.color_scheme ? "_#{theme.color_scheme.id}" : ""
"#{@target}#{scheme_string}"
Expand Down
7 changes: 4 additions & 3 deletions spec/components/stylesheet/manager_spec.rb
Expand Up @@ -193,12 +193,13 @@
SiteSetting.default_theme_id = theme.id

link = 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}_")
end

it "uses the correct scheme when colors are passed" do
link = 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}_")
end

it "does not fail with a color scheme name containing spaces and special characters" do
Expand All @@ -207,7 +208,7 @@
SiteSetting.default_theme_id = theme.id

link = 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}_")
end

end
Expand Down

0 comments on commit f179510

Please sign in to comment.