Skip to content

A platform for community discussion. Free, open, simple.

FIX: Multiple links being generated for non-theme targets.

Alan Guo Xiang Tan7901f735979c
diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb
index c433f90271c..3ce2c06b23f 100644
--- a/lib/stylesheet/manager.rb
+++ b/lib/stylesheet/manager.rb
@@ -201,8 +201,9 @@ class Stylesheet::Manager
@@lock.synchronize do
stylesheets = []
stale_theme_ids = []
+ theme_ids = target.to_s =~ THEME_REGEX ? @theme_ids : [@theme_id]
- @theme_ids.each do |theme_id|
+ theme_ids.each do |theme_id|
cache_key = "path_#{target}_#{theme_id}_#{current_hostname}"
if href = cache[cache_key]
diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rb
index 7efb5084533..a4b083a18df 100644
--- a/spec/components/stylesheet/manager_spec.rb
+++ b/spec/components/stylesheet/manager_spec.rb
@@ -38,6 +38,14 @@ describe Stylesheet::Manager do
t.add_relative_theme!(:child, child_theme)
}}
+ it "generates the right links for non-theme targets" do
+ manager = manager(theme.id)
+
+ hrefs = manager.stylesheet_details(:desktop, 'all')
+
+ expect(hrefs.length).to eq(1)
+ end
+
it 'can correctly compile theme css' do
manager = manager(theme.id)
old_links = manager.stylesheet_link_tag(:desktop_theme, 'all')