From d62da160aea9af222ad8dcdc419fdd3089b29d04 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 12 Feb 2024 14:29:41 +0100 Subject: [PATCH] Refs #37102 - Read real webpack manifest in test In some test cases (like controller tests) the real manifest isn't needed, but in integration tests they are. Rails has deprecated controller tests in favor of integration tests, but Foreman still has them. This modifies the fake read_webpack_manifest to read the manifest if available, otherwise pretend it's there. --- test/test_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index d4fa295e032..2668c568ed5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -66,9 +66,16 @@ def invalid_name_list "\t", ] end + module ReactjsHelper def read_webpack_manifest - {"assetsByChunkName" => {"foreman-vendor" => ["foreman-vendor.js", "foreman-vendor.css"]}} + manifest = Rails.root.join('public/webpack/manifest.json') + if manifest.exist? + JSON.parse(manifest.read) + else + # Stubbed method to deal with a missing manifest for controller tests + {"assetsByChunkName" => {"foreman-vendor" => ["foreman-vendor.js", "foreman-vendor.css"]}} + end end end