Skip to content

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

DEV: Ensure `activatedThemes` key is always available in tests (#40675)

David Taylorefb5c35b5a70
diff --git a/app/controllers/qunit_controller.rb b/app/controllers/qunit_controller.rb
index 5b28e746a6d..1ece51a82d0 100644
--- a/app/controllers/qunit_controller.rb
+++ b/app/controllers/qunit_controller.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class QunitController < ApplicationController
- # Same list maintained in discourse-test-load-dynamic-js.js
ALWAYS_LOADED_PLUGINS = %w[discourse-local-dates]
skip_before_action *%i[
diff --git a/app/helpers/qunit_helper.rb b/app/helpers/qunit_helper.rb
index e94f1d74b81..7c00fab63c6 100644
--- a/app/helpers/qunit_helper.rb
+++ b/app/helpers/qunit_helper.rb
@@ -27,9 +27,14 @@ module QunitHelper
def theme_settings_preload_data
theme = Theme.find_by(id: request.env[:resolved_theme_id])
- return {} if theme.blank?
- activated_themes = { theme.id => { name: theme.name, settings: theme.cached_default_settings } }
+ activated_themes =
+ if theme
+ { theme.id => { name: theme.name, settings: theme.cached_default_settings } }
+ else
+ {}
+ end
+
{ "activatedThemes" => activated_themes.to_json }
end