Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/sandbox/app/components/accordion/item_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h2>Item <%= @title %></h2>
<div class="accordion-item">
<%= content %>
</div>
5 changes: 5 additions & 0 deletions test/sandbox/app/components/accordion/item_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Accordion::ItemComponent < ViewComponent::Base
def initialize(title:)
@title = title
end
end
5 changes: 5 additions & 0 deletions test/sandbox/app/components/accordion_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="accordion">
<% items.each do |item| %>
<%= item %>
<% end %>
</div>
3 changes: 3 additions & 0 deletions test/sandbox/app/components/accordion_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AccordionComponent < ViewComponent::Base
renders_many :items, Accordion::ItemComponent
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%= render(AccordionComponent.new) do |accordion| %>
<% accordion.with_item title: :to_classify do %>
<p>Items that need to be classified.</p>
<% end %>

<% accordion.with_item title: :classified do %>
<p>Items that have been classified.</p>
<% end %>

<% accordion.with_item title: :rejected do %>
<p>Items that have been rejected.</p>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions test/sandbox/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions test/sandbox/test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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