A platform for community discussion. Free, open, simple.
Code review comments.
Alan Guo Xiang Tan44aa46ca0593
diff --git a/app/assets/javascripts/discourse/app/lib/theme-selector.js b/app/assets/javascripts/discourse/app/lib/theme-selector.jsindex 32326b4a88b..fdc4cb9517d 100644--- a/app/assets/javascripts/discourse/app/lib/theme-selector.js+++ b/app/assets/javascripts/discourse/app/lib/theme-selector.js@@ -2,7 +2,7 @@ import cookie, { removeCookie } from "discourse/lib/cookie";import I18n from "I18n";import deprecated from "discourse-common/lib/deprecated";-const keySelector = "meta[name=discourse_theme_ids]";+const keySelector = "meta[name=discourse_theme_id]";export function currentThemeKey() {// eslint-disable-next-line no-consolediff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.jsindex 7c78d2d1f50..18f7b80c0fe 100644--- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js@@ -34,9 +34,9 @@ function head(buffer, bootstrap) {buffer.push(`<meta name="csrf-param" content="authenticity_token">`);buffer.push(`<meta name="csrf-token" content="${bootstrap.csrf_token}">`);}- if (bootstrap.theme_ids) {+ if (bootstrap.theme_id) {buffer.push(- `<meta name="discourse_theme_ids" content="${bootstrap.theme_ids}">`+ `<meta name="discourse_theme_id" content="${bootstrap.theme_id}">`);}diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.jsindex 6869f9fbad9..312fd2a82a1 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js@@ -100,7 +100,7 @@ acceptance("User Preferences - Interface", function (needs) {test("shows no default option for light scheme when theme's color scheme is user selectable", async function (assert) {let meta = document.createElement("meta");- meta.name = "discourse_theme_ids";+ meta.name = "discourse_theme_id";meta.content = "2";document.getElementsByTagName("head")[0].appendChild(meta);@@ -128,7 +128,7 @@ acceptance("User Preferences - Interface", function (needs) {await selectKit(".light-color-scheme .select-kit").expand();assert.equal(count(".light-color-scheme .select-kit .select-kit-row"), 2);- document.querySelector("meta[name='discourse_theme_ids']").remove();+ document.querySelector("meta[name='discourse_theme_id']").remove();});});diff --git a/app/controllers/bootstrap_controller.rb b/app/controllers/bootstrap_controller.rbindex 5bb4dc6ddb3..7840dcab3e2 100644--- a/app/controllers/bootstrap_controller.rb+++ b/app/controllers/bootstrap_controller.rb@@ -51,7 +51,7 @@ class BootstrapController < ApplicationController).map { |f| script_asset_path(f) }bootstrap = {- theme_ids: [theme_id],+ theme_id: theme_id,title: SiteSetting.title,current_homepage: current_homepage,locale_script: locale,diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rbindex 427f2b9203a..df53cf58030 100644--- a/app/controllers/stylesheets_controller.rb+++ b/app/controllers/stylesheets_controller.rb@@ -47,7 +47,7 @@ class StylesheetsController < ApplicationControllertheme_id =if target.include?("theme")split_target, theme_id = target.split(/_(-?[0-9]+)/)- Theme.where(id: theme_id).pluck_first(:id) if theme_id.present?+ theme_id if theme_id.present? && Theme.exists?(id: theme_id)elsesplit_target, color_scheme_id = target.split(/_(-?[0-9]+)/)Theme.where(color_scheme_id: color_scheme_id).pluck_first(:id)diff --git a/app/models/theme.rb b/app/models/theme.rbindex ad5f63be4c5..fe71405f192 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -203,6 +203,7 @@ class Theme < ActiveRecord::Basedef self.transform_ids(id)return [] if id.blank?+ id = id.to_iget_set_cache "transformed_ids_#{id}" doall_ids =@@ -297,8 +298,7 @@ class Theme < ActiveRecord::Baseenddef self.lookup_modifier(theme_ids, modifier_name)- theme_ids = [theme_ids] unless Array === theme_ids- theme_ids = transform_ids(theme_ids)+ theme_ids = [theme_ids] unless theme_ids.is_a?(Array)get_set_cache("#{theme_ids.join(",")}:modifier:#{modifier_name}:#{Theme.compiler_version}") doThemeModifierSet.resolve_modifier_for_themes(theme_ids, modifier_name)@@ -350,7 +350,7 @@ class Theme < ActiveRecord::Baseenddef self.refresh_message_for_targets(targets, theme_ids)- theme_ids = [theme_ids] unless theme_ids === Array+ theme_ids = [theme_ids] unless theme_ids.is_a?(Array)targets.each_with_object([]) do |target, data|theme_ids.each do |theme_id|diff --git a/app/views/common/_discourse_publish_stylesheet.html.erb b/app/views/common/_discourse_publish_stylesheet.html.erbindex 90fe9a9f9e2..ae48d98f98f 100644--- a/app/views/common/_discourse_publish_stylesheet.html.erb+++ b/app/views/common/_discourse_publish_stylesheet.html.erb@@ -1,4 +1,4 @@-<%= discourse_stylesheet_link_tag 'publish', theme_ids: nil %>+<%= discourse_stylesheet_link_tag 'publish', theme_id: nil %><%- if rtl? %><%= discourse_stylesheet_link_tag(mobile_view? ? :publish_mobile_rtl : :publish_mobile_rtl) %>diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erbindex 47159a614a5..b5ec502ee61 100644--- a/app/views/layouts/application.html.erb+++ b/app/views/layouts/application.html.erb@@ -5,7 +5,7 @@<meta charset="utf-8"><title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title><meta name="description" content="<%= @description_meta || SiteSetting.site_description %>">- <meta name="discourse_theme_ids" content="<%= theme_id %>">+ <meta name="discourse_theme_id" content="<%= theme_id %>"><meta name="discourse_current_homepage" content="<%= current_homepage %>"><%= render partial: "layouts/head" %><%= discourse_csrf_tags %>@@ -90,6 +90,9 @@<%- unless customization_disabled? %><%= theme_lookup("header") %>+ <%- end %>++ <%- if allow_plugins? %><%= build_plugin_html 'server:header' %><%- end %>@@ -115,6 +118,9 @@<%- unless customization_disabled? %><%= theme_lookup("body_tag") %><%- end %>- <%= build_plugin_html 'server:before-body-close' %>++ <%- if allow_plugins? %>+ <%= build_plugin_html 'server:before-body-close' %>+ <%- end %></body></html>diff --git a/app/views/layouts/embed.html.erb b/app/views/layouts/embed.html.erbindex 42b70d08fe5..90711df5d2c 100644--- a/app/views/layouts/embed.html.erb+++ b/app/views/layouts/embed.html.erb@@ -3,7 +3,7 @@<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">- <%= discourse_stylesheet_link_tag 'embed', theme_ids: nil %>+ <%= discourse_stylesheet_link_tag 'embed', theme_id: nil %><%- unless customization_disabled? %><%= discourse_stylesheet_link_tag :embedded_theme %><%- end %>diff --git a/app/views/layouts/finish_installation.html.erb b/app/views/layouts/finish_installation.html.erbindex 22c2b04e55f..4cff210af79 100644--- a/app/views/layouts/finish_installation.html.erb+++ b/app/views/layouts/finish_installation.html.erb@@ -1,6 +1,6 @@<html><head>- <%= discourse_stylesheet_link_tag 'wizard', theme_ids: nil %>+ <%= discourse_stylesheet_link_tag 'wizard', theme_id: nil %><%= discourse_color_scheme_stylesheets %><%= render partial: "layouts/head" %>diff --git a/app/views/layouts/no_ember.html.erb b/app/views/layouts/no_ember.html.erbindex b36b9205b5d..c11948d364c 100644--- a/app/views/layouts/no_ember.html.erb+++ b/app/views/layouts/no_ember.html.erb@@ -8,13 +8,22 @@<%= render partial: "common/discourse_stylesheet" %><%= discourse_csrf_tags %>- <%= theme_lookup("head_tag") %>+ <%- unless customization_disabled? %>+ <%= theme_lookup("head_tag") %>+ <%- end %>+<%= yield(:no_ember_head) %>- <%= build_plugin_html 'server:before-head-close' %>++ <%- if allow_plugins? %>+ <%= build_plugin_html 'server:before-head-close' %>+ <%- end -%></head><body class="no-ember <%= @custom_body_class %>"><%- unless customization_disabled? %><%= theme_lookup("header") %>+ <%- end %>++ <%- if allow_plugins? %><%= build_plugin_html 'server:header' %><%- end %>@@ -24,9 +33,15 @@<%= yield %></div></section>- <%= theme_lookup("footer") %>- <%= theme_lookup("body_tag") %>- <%= build_plugin_html 'no-client:footer' %>- <%= build_plugin_html 'server:before-body-close' %>++ <%- unless customization_disabled? %>+ <%= theme_lookup("footer") %>+ <%= theme_lookup("body_tag") %>+ <%- end %>++ <%- if allow_plugins? %>+ <%= build_plugin_html 'no-client:footer' %>+ <%= build_plugin_html 'server:before-body-close' %>+ <%- end %></body></html>diff --git a/app/views/qunit/index.html.erb b/app/views/qunit/index.html.erbindex d4d072376e3..00c92302e02 100644--- a/app/views/qunit/index.html.erb+++ b/app/views/qunit/index.html.erb@@ -3,8 +3,8 @@<head><title>QUnit Test Runner</title><%= discourse_color_scheme_stylesheets %>- <%= discourse_stylesheet_link_tag(:desktop, theme_ids: nil) %>- <%= discourse_stylesheet_link_tag(:test_helper, theme_ids: nil) %>+ <%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>+ <%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %><%= preload_script "discourse/tests/test_helper" %><%= preload_script "discourse/tests/core_plugins_tests" %><%= preload_script "discourse/tests/test_starter" %>diff --git a/app/views/qunit/theme.html.erb b/app/views/qunit/theme.html.erbindex 3016de7711f..412dcb8c0d1 100644--- a/app/views/qunit/theme.html.erb+++ b/app/views/qunit/theme.html.erb@@ -4,8 +4,8 @@<title>Theme QUnit Test Runner</title><%= discourse_color_scheme_stylesheets %><%- if !@suggested_themes %>- <%= discourse_stylesheet_link_tag(:desktop, theme_ids: nil) %>- <%= discourse_stylesheet_link_tag(:test_helper, theme_ids: nil) %>+ <%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>+ <%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %><%= preload_script "locales/en" %><%= preload_script "discourse/tests/theme_qunit_ember_jquery" %><%= preload_script "discourse/tests/theme_qunit_vendor" %>diff --git a/app/views/wizard/index.html.erb b/app/views/wizard/index.html.erbindex 5765863cfa7..7fb1c7332c9 100644--- a/app/views/wizard/index.html.erb+++ b/app/views/wizard/index.html.erb@@ -1,6 +1,6 @@<html class="discourse-wizard"><head>- <%= discourse_stylesheet_link_tag :wizard, theme_ids: nil %>+ <%= discourse_stylesheet_link_tag :wizard, theme_id: nil %><%= discourse_color_scheme_stylesheets %><%= preload_script "locales/#{I18n.locale}" %><%- if ExtraLocalesController.client_overrides_exist? %>diff --git a/app/views/wizard/qunit.html.erb b/app/views/wizard/qunit.html.erbindex f1e767d9c0a..52e1ffaf901 100644--- a/app/views/wizard/qunit.html.erb+++ b/app/views/wizard/qunit.html.erb@@ -2,8 +2,8 @@<html><head><title>QUnit Test Runner</title>- <%= discourse_stylesheet_link_tag(:test_helper, theme_ids: nil) %>- <%= discourse_stylesheet_link_tag :wizard, theme_ids: nil %>+ <%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %>+ <%= discourse_stylesheet_link_tag :wizard, theme_id: nil %><%= preload_script "wizard/test/test_helper" %><%= csrf_meta_tags %><script src="<%= ExtraLocalesController.url("wizard") %>"></script>diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rbindex d9282465976..7826354e26d 100644--- a/lib/stylesheet/importer.rb+++ b/lib/stylesheet/importer.rb@@ -173,6 +173,8 @@ module Stylesheetenddef theme_import(target)+ return "" if !@theme_id+attr = target == :embedded_theme ? :embedded_scss : :scsstarget = target.to_s.gsub("_theme", "").to_symdiff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rbindex 2f4b6791619..42f96e45535 100644--- a/lib/stylesheet/manager.rb+++ b/lib/stylesheet/manager.rb@@ -134,7 +134,7 @@ class Stylesheet::Managerattr_reader :theme_idsdef initialize(theme_id: nil)- @theme_id = theme_id || SiteSetting.default_theme_id+ @theme_id = theme_id@theme_ids = Theme.transform_ids(@theme_id)@themes_cache = {}end@@ -218,16 +218,23 @@ class Stylesheet::Managerscss_checker = ScssChecker.new(target, stale_theme_ids)- load_themes(stale_theme_ids).each do |theme|- theme_id = theme.id+ themes = @theme_id.blank? ? [nil] : load_themes(stale_theme_ids)++ themes.each do |theme|+ theme_id = theme&.iddata = { target: target, theme_id: theme_id }builder = Builder.new(target: target, theme: theme, manager: self)+ is_theme = builder.is_theme?+ has_theme = builder.theme.present?- next if builder.theme.component && !scss_checker.has_scss(theme_id)- builder.compile unless File.exists?(builder.stylesheet_fullpath)- href = builder.stylesheet_path(current_hostname)-- cache.defer_set("path_#{target}_#{theme_id}_#{current_hostname}", href)+ if is_theme && !has_theme+ next+ else+ next if builder.theme&.component && !scss_checker.has_scss(theme_id)+ builder.compile unless File.exists?(builder.stylesheet_fullpath)+ href = builder.stylesheet_path(current_hostname)+ cache.defer_set("path_#{target}_#{theme_id}_#{current_hostname}", href)+ enddata[:new_href] = hrefstylesheets << data@@ -239,7 +246,7 @@ class Stylesheet::Managerenddef color_scheme_stylesheet_details(color_scheme_id = nil, media)- theme_id = @theme_ids.first+ theme_id = @theme_id || SiteSetting.default_theme_idcolor_scheme = beginColorScheme.find(color_scheme_id)diff --git a/lib/stylesheet/manager/builder.rb b/lib/stylesheet/manager/builder.rbindex a04de17edea..1265c286a6c 100644--- a/lib/stylesheet/manager/builder.rb+++ b/lib/stylesheet/manager/builder.rb@@ -3,7 +3,7 @@class Stylesheet::Manager::Builderattr_reader :theme- def initialize(target: :desktop, theme:, color_scheme: nil, manager:)+ def initialize(target: :desktop, theme: nil, color_scheme: nil, manager:)@target = target@theme = theme@color_scheme = color_scheme@@ -115,11 +115,11 @@ class Stylesheet::Manager::Builderdef qualified_targetif is_theme?- "#{@target}_#{theme.id}"+ "#{@target}_#{theme&.id}"elsif @color_scheme"#{@target}_#{scheme_slug}_#{@color_scheme&.id.to_s}"else- scheme_string = theme && theme.color_scheme ? "_#{theme.color_scheme.id}" : ""+ scheme_string = theme&.color_scheme ? "_#{theme.color_scheme.id}" : """#{@target}#{scheme_string}"endend@@ -186,10 +186,10 @@ class Stylesheet::Manager::Builderenddef settings_digest- theme_ids = Theme.is_parent_theme?(theme.id) ? @manager.theme_ids : [theme.id]-themes =- if Theme.is_parent_theme?(theme.id)+ if !theme+ []+ elsif Theme.is_parent_theme?(theme.id)@manager.load_themes(@manager.theme_ids)else[@manager.get_theme(theme.id)]@@ -211,7 +211,7 @@ class Stylesheet::Manager::Builderdef uploads_digestsha1s = []- theme.upload_fields.map do |upload_field|+ (theme&.upload_fields || []).map do |upload_field|sha1s << upload_field.upload.sha1end@@ -247,7 +247,9 @@ class Stylesheet::Manager::Builderdef resolve_baked_field(target, name)theme_ids =- if Theme.is_parent_theme?(theme.id)+ if !theme+ []+ elsif Theme.is_parent_theme?(theme.id)@manager.theme_idselse[theme.id]diff --git a/lib/svg_sprite/svg_sprite.rb b/lib/svg_sprite/svg_sprite.rbindex 0754ab7b2a4..c9eb7340c3d 100644--- a/lib/svg_sprite/svg_sprite.rb+++ b/lib/svg_sprite/svg_sprite.rb@@ -358,7 +358,7 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFLdef self.search(searched_icon)searched_icon = process(searched_icon.dup)- sprite_sources([SiteSetting.default_theme_id]).each do |fname|+ sprite_sources(SiteSetting.default_theme_id).each do |fname|next if !File.exist?(fname)svg_file = Nokogiri::XML(File.open(fname))@@ -381,7 +381,7 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFLdef self.icon_picker_search(keyword)results = Set.new- sprite_sources([SiteSetting.default_theme_id]).each do |fname|+ sprite_sources(SiteSetting.default_theme_id).each do |fname|next if !File.exist?(fname)svg_file = Nokogiri::XML(File.open(fname))@@ -465,9 +465,10 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFLreturn [] if theme_id.blank?theme_icon_settings = []+ theme_ids = Theme.transform_ids(theme_id)# Need to load full records for default values- Theme.where(id: Theme.transform_ids(theme_id)).each do |theme|+ Theme.where(id: theme_ids).each do |theme|settings = theme.cached_settings.each do |key, value|if key.to_s.include?("_icon") && String === valuetheme_icon_settings |= value.split('|')@@ -475,7 +476,7 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFLendend- theme_icon_settings |= ThemeModifierHelper.new(theme_ids: [theme_id]).svg_icons+ theme_icon_settings |= ThemeModifierHelper.new(theme_ids: theme_ids).svg_iconstheme_icon_settingsenddiff --git a/lib/theme_modifier_helper.rb b/lib/theme_modifier_helper.rbindex 2299d179f9c..8f6be146916 100644--- a/lib/theme_modifier_helper.rb+++ b/lib/theme_modifier_helper.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueclass ThemeModifierHelperdef initialize(request: nil, theme_ids: nil)- @theme_ids = theme_ids || [request&.env&.[](:resolved_theme_id)]+ @theme_ids = theme_ids || Theme.transform_ids(request&.env&.[](:resolved_theme_id))endThemeModifierSet.modifiers.keys.each do |modifier|diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex cf4b35e8e45..7b64c8d4d5c 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -12,12 +12,6 @@ describe Stylesheet::Manager doTheme.clear_default!link = manager.stylesheet_link_tag(:embedded_theme)expect(link).to eq("")-- theme = Fabricate(:theme)- SiteSetting.default_theme_id = theme.id-- link = manager.stylesheet_link_tag(:embedded_theme)- expect(link).not_to eq("")endit "still returns something for no themes" dodiff --git a/spec/components/svg_sprite/svg_sprite_spec.rb b/spec/components/svg_sprite/svg_sprite_spec.rbindex 3494d6f1723..584800ea028 100644--- a/spec/components/svg_sprite/svg_sprite_spec.rb+++ b/spec/components/svg_sprite/svg_sprite_spec.rb@@ -139,12 +139,21 @@ describe SvgSprite doit 'includes icons defined in theme modifiers' dotheme = Fabricate(:theme)+ child_theme = Fabricate(:theme, component: true)+ theme.add_relative_theme!(:child, child_theme)expect(SvgSprite.all_icons(theme.id)).not_to include("dragon")theme.theme_modifier_set.svg_icons = ["dragon"]theme.save!- expect(SvgSprite.all_icons(theme.id)).to include("dragon")++ child_theme.theme_modifier_set.svg_icons = ["fly"]+ child_theme.save!++ icons = SvgSprite.all_icons(theme.id)++ expect(icons).to include("dragon")+ expect(icons).to include("fly")endit 'includes custom icons from a sprite in a theme' dodiff --git a/spec/fixtures/onebox/discourse_topic.response b/spec/fixtures/onebox/discourse_topic.responseindex 00a0e24fe99..18ef0d722f1 100644--- a/spec/fixtures/onebox/discourse_topic.response+++ b/spec/fixtures/onebox/discourse_topic.response@@ -9,7 +9,7 @@[image]And that too in just over an year, way to go! [boom]">- <meta name="discourse_theme_ids" content="28">+ <meta name="discourse_theme_id" content="28"><meta name="discourse_current_homepage" content="latest"><meta name="generator" content="Discourse 2.4.0.beta10 - https://github.com/discourse/discourse version c84652eb8b2bb9dd616056621ee7c7b91fcf64a2"><link rel="icon" type="image/png" href="https://d11a6trkgmumsb.cloudfront.net/optimized/3X/b/3/b33be9538df3547fcf9d1a51a4637d77392ac6f9_2_32x32.png">diff --git a/spec/fixtures/onebox/discourse_topic_reply.response b/spec/fixtures/onebox/discourse_topic_reply.responseindex d204320e713..36a5e7a4008 100644--- a/spec/fixtures/onebox/discourse_topic_reply.response+++ b/spec/fixtures/onebox/discourse_topic_reply.response@@ -9,7 +9,7 @@[image]And that too in just over an year, way to go! [boom]">- <meta name="discourse_theme_ids" content="28">+ <meta name="discourse_theme_id" content="28"><meta name="discourse_current_homepage" content="latest"><meta name="generator" content="Discourse 2.4.0.beta10 - https://github.com/discourse/discourse version c84652eb8b2bb9dd616056621ee7c7b91fcf64a2"><link rel="icon" type="image/png" href="https://d11a6trkgmumsb.cloudfront.net/optimized/3X/b/3/b33be9538df3547fcf9d1a51a4637d77392ac6f9_2_32x32.png">diff --git a/spec/lib/content_security_policy_spec.rb b/spec/lib/content_security_policy_spec.rbindex 32a4db46d34..20ea52d3b25 100644--- a/spec/lib/content_security_policy_spec.rb+++ b/spec/lib/content_security_policy_spec.rb@@ -274,7 +274,7 @@ describe ContentSecurityPolicy do}def theme_policy- policy([theme.id])+ policy(theme.id)endit 'can be extended by themes' do@@ -303,13 +303,23 @@ describe ContentSecurityPolicy dotheme.theme_modifier_set.csp_extensions = ["script-src: https://from-theme-flag.script", "worker-src: from-theme-flag.worker"]theme.save!+ child_theme = Fabricate(:theme, component: true)+ theme.add_relative_theme!(:child, child_theme)+ child_theme.theme_modifier_set.csp_extensions = ["script-src: https://child-theme-flag.script", "worker-src: child-theme-flag.worker"]+ child_theme.save!+expect(parse(theme_policy)['script-src']).to include('https://from-theme-flag.script')+ expect(parse(theme_policy)['script-src']).to include('https://child-theme-flag.script')expect(parse(theme_policy)['worker-src']).to include('from-theme-flag.worker')+ expect(parse(theme_policy)['worker-src']).to include('child-theme-flag.worker')theme.destroy!+ child_theme.destroy!expect(parse(theme_policy)['script-src']).to_not include('https://from-theme-flag.script')expect(parse(theme_policy)['worker-src']).to_not include('from-theme-flag.worker')+ expect(parse(theme_policy)['worker-src']).to_not include('from-theme-flag.worker')+ expect(parse(theme_policy)['worker-src']).to_not include('child-theme-flag.worker')endit 'is extended automatically when themes reference external scripts' do@@ -352,7 +362,7 @@ describe ContentSecurityPolicy doend.to_hend- def policy(theme_ids = [], path_info: "/")- ContentSecurityPolicy.policy(theme_ids, path_info: path_info)+ def policy(theme_id = nil, path_info: "/")+ ContentSecurityPolicy.policy(theme_id, path_info: path_info)endenddiff --git a/spec/requests/bootstrap_controller_spec.rb b/spec/requests/bootstrap_controller_spec.rbindex 182c307191c..cd61f711146 100644--- a/spec/requests/bootstrap_controller_spec.rb+++ b/spec/requests/bootstrap_controller_spec.rb@@ -27,7 +27,7 @@ describe BootstrapController dobootstrap = json['bootstrap']expect(bootstrap).to be_presentexpect(bootstrap['title']).to be_present- expect(bootstrap['theme_ids']).to eq([theme.id])+ expect(bootstrap['theme_id']).to eq(theme.id)expect(bootstrap['setup_data']['base_url']).to eq(Discourse.base_url)expect(bootstrap['stylesheets']).to be_presentdiff --git a/spec/requests/safe_mode_controller_spec.rb b/spec/requests/safe_mode_controller_spec.rbindex 871e1c5dc33..12e1f330668 100644--- a/spec/requests/safe_mode_controller_spec.rb+++ b/spec/requests/safe_mode_controller_spec.rb@@ -10,10 +10,18 @@ RSpec.describe SafeModeController dotheme.save!theme.set_default!+ Fabricate(:admin) # Avoid wizard page++ get '/'++ expect(response.status).to eq(200)+ expect(response.body).to include("data-theme-id=\"#{theme.id}\"")+get '/safe-mode'expect(response.status).to eq(200)expect(response.body).not_to include("My Custom Header")+ expect(response.body).not_to include("data-theme-id=\"#{theme.id}\"")endenddiff --git a/spec/requests/svg_sprite_controller_spec.rb b/spec/requests/svg_sprite_controller_spec.rbindex 60584b8ea8b..047e0e462fe 100644--- a/spec/requests/svg_sprite_controller_spec.rb+++ b/spec/requests/svg_sprite_controller_spec.rb@@ -16,7 +16,7 @@ describe SvgSpriteController dotheme = Fabricate(:theme)theme.set_field(target: :settings, name: :yaml, value: "custom_icon: dragon")theme.save!- get "/svg-sprite/#{Discourse.current_hostname}/svg-#{theme.id}-#{SvgSprite.version([theme.id])}.js"+ get "/svg-sprite/#{Discourse.current_hostname}/svg-#{theme.id}-#{SvgSprite.version(theme.id)}.js"expect(response.status).to eq(200)enddiff --git a/spec/serializers/listable_topic_serializer_spec.rb b/spec/serializers/listable_topic_serializer_spec.rbnew file mode 100644index 00000000000..098a5034e5e--- /dev/null+++ b/spec/serializers/listable_topic_serializer_spec.rb@@ -0,0 +1,41 @@+# frozen_string_literal: true+require 'rails_helper'++describe ListableTopicSerializer do+ fab!(:topic) { Fabricate(:topic) }++ describe '#excerpt' do+ it 'can be extended by theme modifiers' do+ payload = TopicListItemSerializer.new(topic,+ scope: Guardian.new,+ root: false+ ).as_json++ expect(payload[:excerpt]).to eq(nil)++ theme = Fabricate(:theme)++ child_theme = Fabricate(:theme, component: true).tap do |t|+ theme.add_relative_theme!(:child, t)+ end++ child_theme.theme_modifier_set.serialize_topic_excerpts = true+ child_theme.save!++ request = ActionController::TestRequest.new(+ { resolved_theme_id: theme.id },+ nil,+ nil+ )++ guardian = Guardian.new(nil, request)++ payload = TopicListItemSerializer.new(topic,+ scope: guardian,+ root: false+ ).as_json++ expect(payload[:excerpt]).to eq(topic.excerpt)+ end+ end+end