diff --git a/app/controllers/view_components_system_test_controller.rb b/app/controllers/view_components_system_test_controller.rb index 949f805ed3..89c3dde5e7 100644 --- a/app/controllers/view_components_system_test_controller.rb +++ b/app/controllers/view_components_system_test_controller.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -require "rails/application_controller" - -class ViewComponentsSystemTestController < Rails::ApplicationController # :nodoc: +class ViewComponentsSystemTestController < ActionController::Base # :nodoc: def system_test_entrypoint render file: "./tmp/view_components/#{params.permit(:file)[:file]}" end diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 70b1836a25..eee45b6c46 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 5 ## main +* Fix tests using `with_rendered_component_path` with custom layouts. + + *Ian Hollander* + ## 2.81.0 * Adjust the way response objects are set on the preview controller to work around a recent change in Rails main. diff --git a/docs/index.md b/docs/index.md index 7e10297db8..10fc63b3b5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -205,6 +205,7 @@ ViewComponent is built by over a hundred members of the community, including: yykamei matheuspolicamilo erinnachen +ihollander ## Who uses ViewComponent? diff --git a/test/sandbox/app/views/layouts/application.html.erb b/test/sandbox/app/views/layouts/application.html.erb index 713887297b..0a9d7c1c60 100644 --- a/test/sandbox/app/views/layouts/application.html.erb +++ b/test/sandbox/app/views/layouts/application.html.erb @@ -6,15 +6,15 @@ <%= yield %> - - - + + + diff --git a/test/sandbox/test/view_component_system_test.rb b/test/sandbox/test/view_component_system_test.rb index f24d10e8f2..1875873d47 100644 --- a/test/sandbox/test/view_component_system_test.rb +++ b/test/sandbox/test/view_component_system_test.rb @@ -44,4 +44,13 @@ def test_components_with_slots find(".title", text: "This is my title!") end end + + def test_layout_is_not_nested + with_rendered_component_path(render_inline(MyComponent.new), layout: "application") do |path| + visit path + + assert find("div", text: "hello,world!") + assert_no_selector "body > title", visible: false + end + end end