diff --git a/test/sandbox/app/components/accordion/item_component.html.erb b/test/sandbox/app/components/accordion/item_component.html.erb new file mode 100644 index 000000000..1f0f16e5e --- /dev/null +++ b/test/sandbox/app/components/accordion/item_component.html.erb @@ -0,0 +1,4 @@ +

Item <%= @title %>

+
+ <%= content %> +
diff --git a/test/sandbox/app/components/accordion/item_component.rb b/test/sandbox/app/components/accordion/item_component.rb new file mode 100644 index 000000000..de7aa7735 --- /dev/null +++ b/test/sandbox/app/components/accordion/item_component.rb @@ -0,0 +1,5 @@ +class Accordion::ItemComponent < ViewComponent::Base + def initialize(title:) + @title = title + end +end diff --git a/test/sandbox/app/components/accordion_component.html.erb b/test/sandbox/app/components/accordion_component.html.erb new file mode 100644 index 000000000..75e84e90b --- /dev/null +++ b/test/sandbox/app/components/accordion_component.html.erb @@ -0,0 +1,5 @@ +
+ <% items.each do |item| %> + <%= item %> + <% end %> +
diff --git a/test/sandbox/app/components/accordion_component.rb b/test/sandbox/app/components/accordion_component.rb new file mode 100644 index 000000000..7bc542e74 --- /dev/null +++ b/test/sandbox/app/components/accordion_component.rb @@ -0,0 +1,3 @@ +class AccordionComponent < ViewComponent::Base + renders_many :items, Accordion::ItemComponent +end diff --git a/test/sandbox/app/views/integration_examples/slot_component_child_content_block.html.erb b/test/sandbox/app/views/integration_examples/slot_component_child_content_block.html.erb new file mode 100644 index 000000000..47f12538c --- /dev/null +++ b/test/sandbox/app/views/integration_examples/slot_component_child_content_block.html.erb @@ -0,0 +1,13 @@ +<%= render(AccordionComponent.new) do |accordion| %> + <% accordion.with_item title: :to_classify do %> +

Items that need to be classified.

+ <% end %> + + <% accordion.with_item title: :classified do %> +

Items that have been classified.

+ <% end %> + + <% accordion.with_item title: :rejected do %> +

Items that have been rejected.

+ <% end %> +<% end %> diff --git a/test/sandbox/config/routes.rb b/test/sandbox/config/routes.rb index 6bdb4525d..206d27863 100644 --- a/test/sandbox/config/routes.rb +++ b/test/sandbox/config/routes.rb @@ -4,6 +4,7 @@ root to: "integration_examples#index" get :slots, to: "integration_examples#slots" get :empty_slot, to: "integration_examples#empty_slot" + get :slot_component_child_content_block, to: "integration_examples#slot_component_child_content_block" get :partial, to: "integration_examples#partial" get :content, to: "integration_examples#content" get :variants, to: "integration_examples#variants" diff --git a/test/sandbox/test/integration_test.rb b/test/sandbox/test/integration_test.rb index d7e123717..a25f746dd 100644 --- a/test/sandbox/test/integration_test.rb +++ b/test/sandbox/test/integration_test.rb @@ -793,4 +793,10 @@ def test_renders_preview_from_custom_preview_path assert_select "div", "hello,world!" end + + def test_renders_slot_component_child_content_block + get "/slot_component_child_content_block" + + assert_select ".accordion-item", "Items that have been classified." + end end