-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a failing test case for rendering a partial with a block from phlex
- Loading branch information
1 parent
2ac2756
commit 15bc835
Showing
7 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class RenderingController < ApplicationController | ||
def partial_from_phlex | ||
render Rendering::PartialFromPhlex.new | ||
end | ||
|
||
def view_component_from_phlex | ||
render Rendering::ViewComponentFromPhlex.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div id="erb"> | ||
<%= yield %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Rendering | ||
class PartialFromPhlex < ApplicationView | ||
def view_template | ||
render "partial" do | ||
h1(id: "phlex") { "Partial from Phlex" } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Rendering | ||
class VcComponent < ViewComponent::Base | ||
renders_one :slot | ||
|
||
def call | ||
if slot? | ||
slot | ||
end | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
test/dummy/app/views/rendering/view_component_from_phlex.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Rendering | ||
class ViewComponentFromPhlex < ApplicationView | ||
def view_template | ||
render VcComponent.new do |component| | ||
component.slot do | ||
p { "Rendered from Phlex" } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class RenderTest < ActionDispatch::IntegrationTest | ||
test "rendering partial from Phlex view" do | ||
get "/rendering/partial_from_phlex" | ||
assert_response :success | ||
assert_select "#erb>h1#phlex", "Partial from Phlex" | ||
end | ||
|
||
test "rendering view_component component from Phlex view" do | ||
get "/rendering/view_component_from_phlex" | ||
assert_response :success | ||
end | ||
end |