Skip to content

Commit

Permalink
Refs #37102 - Read real webpack manifest in test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ekohl authored and MariaAga committed Feb 14, 2024
1 parent 65481d9 commit d62da16
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d62da16

Please sign in to comment.