A platform for community discussion. Free, open, simple.
FIX: Components mobile-specific CSS was missing (#12259)
Osama Sayeghc0e2fdd20075
diff --git a/app/models/theme.rb b/app/models/theme.rbindex e23bfbfd4cd..66888135f75 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -356,6 +356,8 @@ class Theme < ActiveRecord::Baseif target == :translationsfields = ThemeField.find_first_locale_fields(theme_ids, I18n.fallbacks[name])else+ target = :mobile if target == :mobile_theme+ target = :desktop if target == :desktop_themefields = ThemeField.find_by_theme_ids(theme_ids).where(target_id: [Theme.targets[target], Theme.targets[:common]])fields = fields.where(name: name.to_s) unless name.nil?diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex d4f935d4173..97ab426f617 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -119,6 +119,17 @@ describe Stylesheet::Manager doexpect(hrefs.count).to eq(3) # theme + child_theme + embedded_scss_childend+ it '.stylesheet_details can find components mobile SCSS when target is `:mobile_theme`' do+ child_with_mobile_scss = Fabricate(:theme, component: true)+ child_with_mobile_scss.set_field(target: :mobile, name: :scss, value: "body { color: red; }")+ child_with_mobile_scss.save!+ theme.add_relative_theme!(:child, child_with_mobile_scss)++ hrefs = Stylesheet::Manager.stylesheet_details(:mobile_theme, 'all', [theme.id])+ expect(hrefs.find { |h| h[:theme_id] == child_with_mobile_scss.id }).to be_present+ expect(hrefs.count).to eq(3)+ end+it 'does not output multiple assets for non-theme targets' dohrefs = Stylesheet::Manager.stylesheet_details(:admin, 'all', [theme.id])expect(hrefs.count).to eq(1)