Skip to content

Commit d30ed47

Browse files
committed
Address render component review feedback
1 parent 463304a commit d30ed47

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Changes since the last non-beta release.
1616
_Please add entries here for your pull requests that have not yet been released. Include LINKS for PRs and committers._
1717

1818
#### Fixed
19-
- Preserve default controller layouts for `render component:` after the Rails 8 render pipeline change reported in #1356.
19+
- Preserve default controller layouts for `render component:` after the Rails 8 render pipeline change. [PR 1418](https://github.com/reactjs/react-rails/pull/1418) by [justin808](https://github.com/justin808). Fixes [#1356](https://github.com/reactjs/react-rails/issues/1356).
2020

2121
## [3.3.0] - 2026-03-31
2222

test/react/rails/component_renderer_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def default_layout
1313
def explicit_layout_false
1414
render component: "TodoList", layout: false
1515
end
16+
17+
def explicit_named_layout
18+
render component: "TodoList", layout: "app_no_turbolinks"
19+
end
1620
end
1721

1822
class ComponentRendererTest < ActionController::TestCase
@@ -34,6 +38,7 @@ def call(component_name, options)
3438
@routes.draw do
3539
get "default_layout", to: "component_renderer#default_layout"
3640
get "explicit_layout_false", to: "component_renderer#explicit_layout_false"
41+
get "explicit_named_layout", to: "component_renderer#explicit_named_layout"
3742
end
3843
end
3944

@@ -62,4 +67,17 @@ def call(component_name, options)
6267
assert_match(%r{<main>SSR</main>}, response.body)
6368
assert_equal "TodoList", fake_renderer.calls.dig(0, 0)
6469
end
70+
71+
test "render component preserves a named layout override" do # rubocop:disable Minitest/MultipleAssertions
72+
fake_renderer = FakeRenderer.new("<main>SSR</main>")
73+
74+
React::Rails::ControllerRenderer.stub(:new, ->(*) { fake_renderer }) do
75+
get :explicit_named_layout
76+
end
77+
78+
assert_response :success
79+
assert_match(/app_no_turbolinks/, response.body)
80+
assert_match(%r{<main>SSR</main>}, response.body)
81+
assert_equal "TodoList", fake_renderer.calls.dig(0, 0)
82+
end
6583
end

test/react/rails/railtie_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class RailtieTest < ActionDispatch::IntegrationTest
5050
render_options = React::Rails::Railtie.component_render_options({ status: :accepted }, "<div>SSR</div>")
5151

5252
assert_equal "<div>SSR</div>", render_options[:inline]
53-
assert render_options[:layout]
53+
assert_same true, render_options[:layout]
5454
assert_equal :accepted, render_options[:status]
5555
end
5656

5757
test "component render options preserve explicit layout overrides" do
5858
render_options = React::Rails::Railtie.component_render_options({ layout: false }, "<div>SSR</div>")
5959

60-
refute render_options[:layout]
60+
assert_same false, render_options[:layout]
6161
end
6262

6363
test "component render options preserve a named layout override" do

0 commit comments

Comments
 (0)