discourse/app/helpers/qunit_helper.rb
Joe 03ffb0bf27
FIX: Defer scripts on theme-tests route (#17171)
Small follow-up to #17063. That PR broke the theme tests route locally.

This PR fixes that.
2022-06-21 12:44:31 +08:00

16 lines
450 B
Ruby

# frozen_string_literal: true
module QunitHelper
def theme_tests
theme = Theme.find_by(id: request.env[:resolved_theme_id])
return "" if theme.blank?
_, digest = theme.baked_js_tests_with_digest
src = "#{GlobalSetting.cdn_url}" \
"#{Discourse.base_path}" \
"/theme-javascripts/tests/#{theme.id}-#{digest}.js" \
"?__ws=#{Discourse.current_hostname}"
"<script defer src='#{src}'></script>".html_safe
end
end