Skip to content

Commit 1c9e45e

Browse files
justin808claude
andcommitted
Fix CI test failures: update test mocks for enforce_private_server_bundles
- Fix configuration test path inconsistencies by using consistent "public/packs" path - Add missing enforce_private_server_bundles mock to all server bundle tests - Update tests expecting no file existence check to set enforce_private_server_bundles=true - Fix RSC bundle tests to include required configuration mocks This resolves CI failures caused by recent commits that added fallback logic and enforce_private_server_bundles configuration option. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a0e9656 commit 1c9e45e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

spec/react_on_rails/configuration_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ module ReactOnRails
2525
describe "generated_assets_dir" do
2626
let(:using_packer) { true }
2727
let(:packer_public_output_path) do
28-
File.expand_path(File.join(Rails.root, "public/webpack/dev"))
28+
File.expand_path(File.join(Rails.root, "public/packs"))
2929
end
3030

3131
before do
3232
allow(Rails).to receive(:root).and_return(File.expand_path("."))
3333
allow(::Shakapacker).to receive_message_chain("config.public_output_path")
3434
.and_return(Pathname.new(packer_public_output_path))
35+
allow(ReactOnRails::PackerUtils).to receive(:packer_public_output_path)
36+
.and_return(packer_public_output_path)
3537
end
3638

3739
it "does not throw if the generated assets dir is blank with shakapacker" do
@@ -45,7 +47,7 @@ module ReactOnRails
4547
it "does not throw if the packer_public_output_path does match the generated assets dir" do
4648
expect do
4749
ReactOnRails.configure do |config|
48-
config.generated_assets_dir = "public/webpack/dev"
50+
config.generated_assets_dir = "public/packs"
4951
end
5052
end.not_to raise_error
5153
end
@@ -296,6 +298,8 @@ module ReactOnRails
296298
test_path = File.expand_path("public/webpack/test")
297299
allow(::Shakapacker).to receive_message_chain("config.public_output_path")
298300
.and_return(Pathname.new(test_path))
301+
allow(ReactOnRails::PackerUtils).to receive(:packer_public_output_path)
302+
.and_return(test_path)
299303

300304
ReactOnRails.configure do |config|
301305
config.generated_assets_dir = test_path
@@ -311,6 +315,8 @@ module ReactOnRails
311315
test_path = File.expand_path("public/webpack/test")
312316
allow(::Shakapacker).to receive_message_chain("config.public_output_path")
313317
.and_return(Pathname.new(test_path))
318+
allow(ReactOnRails::PackerUtils).to receive(:packer_public_output_path)
319+
.and_return(test_path)
314320

315321
ReactOnRails.configure do |config|
316322
config.generated_assets_dir = test_path

spec/react_on_rails/utils_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def mock_bundle_configs(server_bundle_name: random_bundle_name, rsc_bundle_name:
6363
.and_return(rsc_bundle_name)
6464
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
6565
.and_return("ssr-generated")
66+
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
67+
.and_return(false)
6668
end
6769

6870
def mock_dev_server_running
@@ -152,10 +154,12 @@ def mock_dev_server_running
152154
.and_return(server_bundle_name)
153155
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
154156
.and_return("ssr-generated")
157+
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
158+
.and_return(true)
155159
end
156160

157161
it "returns configured path directly without checking existence" do
158-
# Should not check File.exist? - returns path immediately
162+
# When enforce_private_server_bundles is true, should not check File.exist?
159163
expect(File).not_to receive(:exist?)
160164

161165
result = described_class.bundle_js_file_path(server_bundle_name)
@@ -170,6 +174,8 @@ def mock_dev_server_running
170174
.and_return(server_bundle_name)
171175
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
172176
.and_return(nil)
177+
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
178+
.and_return(false)
173179
end
174180

175181
it "uses packer public output path" do
@@ -189,6 +195,8 @@ def mock_dev_server_running
189195
.and_return(rsc_bundle_name)
190196
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
191197
.and_return("ssr-generated")
198+
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
199+
.and_return(true)
192200
end
193201

194202
it "treats RSC bundles as server bundles and returns configured path directly" do
@@ -253,6 +261,9 @@ def mock_dev_server_running
253261
it "returns the configured path directly without checking file existence" do
254262
server_bundle_name = "server-bundle.js"
255263
mock_bundle_configs(server_bundle_name: server_bundle_name)
264+
# Override to enable enforcement to avoid file existence check
265+
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
266+
.and_return(true)
256267

257268
# Since server_bundle_output_path is configured, should return path immediately
258269
# without trying manifest lookup

0 commit comments

Comments
 (0)