Skip to content

Commit bcf084c

Browse files
justin808claude
andcommitted
Clean solution: Remove redundant using_packer? check with proper test handling
Since Shakapacker is required by gemspec, the using_packer? check in bundle_js_file_path is unnecessary for production code. However, tests mock this scenario for validation. Changes: - Remove using_packer? check from main bundle_js_file_path logic - Add guard check in bundle_js_file_path_with_packer for test scenarios - Maintains clean production code while handling test mocking properly - All tests pass including "without packer" scenarios This is the correct approach: main logic assumes Shakapacker is available (as guaranteed by gemspec), while method implementation handles edge cases for comprehensive test coverage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ff9cc79 commit bcf084c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/react_on_rails/utils.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def self.bundle_js_file_path(bundle_name)
7272
# Priority order depends on bundle type:
7373
# SERVER BUNDLES (normal case): Try secure non-public locations first, then manifest, then legacy
7474
# CLIENT BUNDLES (normal case): Try manifest first, then fallback locations
75-
if bundle_name == "manifest.json" || !ReactOnRails::PackerUtils.using_packer?
75+
if bundle_name == "manifest.json"
7676
# Default to the non-hashed name in the specified output directory, which, for legacy
7777
# React on Rails, this is the output directory picked up by the asset pipeline.
7878
# For Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
@@ -83,6 +83,9 @@ def self.bundle_js_file_path(bundle_name)
8383
end
8484

8585
def self.bundle_js_file_path_with_packer(bundle_name)
86+
# Handle test scenarios where packer is mocked as unavailable
87+
return File.join(generated_assets_full_path, bundle_name) unless ReactOnRails::PackerUtils.using_packer?
88+
8689
is_server_bundle = server_bundle?(bundle_name)
8790

8891
if is_server_bundle

0 commit comments

Comments
 (0)