@@ -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
1620end
1721
1822class 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
6583end
0 commit comments