Skip to content

Commit 0d0eace

Browse files
committed
Fix CI failures: update generator tests and Redux auto-registration
- Update generator test expectations for new auto-registration structure - Fix Redux auto-registration to use Redux-connected component - Ensure component name consistency across Redux and non-Redux generators
1 parent d4560d1 commit 0d0eace

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

lib/generators/react_on_rails/react_with_redux_generator.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ def copy_base_files
1919
app/javascript/bundles/HelloWorld/components/HelloWorld.module.css]
2020
base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) }
2121

22-
# Also copy to new auto-registration structure for server-side rendering compatibility
23-
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx",
22+
# Also copy Redux-connected component to auto-registration structure
23+
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.jsx",
2424
"app/javascript/src/HelloWorld/ror_components/HelloWorld.jsx")
2525
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css",
2626
"app/javascript/src/HelloWorld/HelloWorld.module.css")
27-
28-
# Fix CSS import path in the ror_components version
29-
ror_component_file = "app/javascript/src/HelloWorld/ror_components/HelloWorld.jsx"
30-
gsub_file(ror_component_file, "./HelloWorld.module.css", "../HelloWorld.module.css")
3127
end
3228

3329
def copy_base_redux_files

spec/react_on_rails/support/shared_examples/base_generator_examples.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
end
1212

1313
it "creates react directories" do
14-
dirs = %w[components]
15-
dirs.each { |dirname| assert_directory "app/javascript/bundles/HelloWorld/#{dirname}" }
14+
# Auto-registration structure is always created
15+
assert_directory "app/javascript/src/HelloWorld/ror_components"
1616
end
1717

1818
it "copies react files" do
1919
%w[app/controllers/hello_world_controller.rb
20-
app/javascript/bundles/HelloWorld/components/HelloWorld.jsx
2120
config/initializers/react_on_rails.rb
2221
Procfile.dev
2322
Procfile.dev-static
2423
Procfile.dev-static-assets
2524
Procfile.dev-prod-assets].each { |file| assert_file(file) }
25+
26+
# Auto-registration component is always created
27+
assert_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.jsx"
2628
end
2729
end

spec/react_on_rails/support/shared_examples/react_no_redux_generator_examples.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
shared_examples "no_redux_generator" do
44
it "creates appropriate templates" do
5-
assert_file("app/javascript/packs/hello-world-bundle.js") do |contents|
6-
expect(contents).to match("import HelloWorld from '../bundles/HelloWorld/components/HelloWorld';")
7-
end
5+
# No manual bundle for non-Redux (auto-registration only)
6+
assert_no_file("app/javascript/packs/hello-world-bundle.js")
87

98
assert_file("app/views/hello_world/index.html.erb") do |contents|
109
expect(contents).to match(/"HelloWorld"/)

spec/react_on_rails/support/shared_examples/react_with_redux_generator_examples.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
it "creates appropriate templates" do
99
assert_file("app/javascript/packs/hello-world-bundle.js") do |contents|
10-
expect(contents).to match("import HelloWorldApp from '../bundles/HelloWorld/startup/HelloWorldApp';")
10+
expect(contents).to match("import HelloWorld from '../bundles/HelloWorld/startup/HelloWorldApp';")
1111
end
1212
assert_file("app/views/hello_world/index.html.erb") do |contents|
13-
expect(contents).to match(/"HelloWorldApp"/)
13+
expect(contents).to match(/"HelloWorld"/)
1414
end
1515
end
1616

0 commit comments

Comments
 (0)