discourse/app/helpers/qunit_helper.rb
Osama Sayegh a169dc6832
Revert "FEATURE: Allow theme tests to be run in production (#12815)" (#12840)
This reverts commit 7217dcb67a.

https://meta.discourse.org/t/failed-to-bootstrap-due-to-out-of-memory-killer/188141/18?u=osama

Precompiling test_helper.js is so expensive that it can make bootstrap
fail on servers with limited resources (2GB RAM). We will find another
way that doesn't require much resources.
2021-04-26 23:05:58 +03:00

25 lines
675 B
Ruby

# frozen_string_literal: true
module QunitHelper
def theme_tests
theme_ids = request.env[:resolved_theme_ids]
return "" if theme_ids.blank?
skip_transformation = request.env[:skip_theme_ids_transformation]
query = ThemeField
.joins(:theme)
.where(
target_id: Theme.targets[:tests_js],
theme_id: skip_transformation ? theme_ids : Theme.transform_ids(theme_ids)
)
.pluck(:theme_id)
.uniq
.map do |theme_id|
src = "#{GlobalSetting.cdn_url}#{Discourse.base_path}/theme-javascripts/tests/#{theme_id}.js"
"<script src='#{src}'></script>"
end
.join("\n")
.html_safe
end
end