File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ module RenderLiteralHelpers
2020 (send nil? {:render :render_to_string} ({str sym} $_) $...)
2121 PATTERN
2222
23- def_node_matcher :render_inst? , <<-PATTERN
24- (send nil? {:render :render_to_string} (send _ :new ...) ...)
25- PATTERN
26-
2723 def_node_matcher :render_with_options? , <<-PATTERN
2824 (send nil? {:render :render_to_string} (hash $...) ...)
2925 PATTERN
@@ -32,6 +28,10 @@ module RenderLiteralHelpers
3228 (send nil? {:render :render_to_string} (send _ :new ...) ...)
3329 PATTERN
3430
31+ def_node_matcher :render_view_component_instance_with_content? , <<-PATTERN
32+ (send nil? {:render :render_to_string} (send (send _ :new ...) `:with_content ...))
33+ PATTERN
34+
3535 def_node_matcher :render_view_component_collection? , <<-PATTERN
3636 (send nil? {:render :render_to_string} (send _ :with_collection ...) ...)
3737 PATTERN
@@ -45,7 +45,8 @@ def hash_with_literal_keys?(hash)
4545 end
4646
4747 def render_view_component? ( node )
48- render_view_component_instance? ( node ) ||
48+ render_view_component_instance_with_content? ( node ) ||
49+ render_view_component_instance? ( node ) ||
4950 render_view_component_collection? ( node )
5051 end
5152 end
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ def test_render_component_instance_no_offense
6262 assert_equal 0 , cop . offenses . count
6363 end
6464
65+ def test_render_component_instance_with_content_no_offense
66+ erb_investigate cop , <<-ERB , "app/views/foo/index.html.erb"
67+ <%= render MyClass . new ( title : "foo" , bar : "baz" ) . with_content ( "foo" ) %>
68+ ERB
69+
70+ assert_equal 0 , cop . offenses . count
71+ end
72+
6573 def test_render_component_instance_block_no_offense
6674 erb_investigate cop , <<-ERB , "app/views/foo/index.html.erb"
6775 <%= render Module ::MyClass . new ( title : "foo" , bar : "baz" ) do %> Content<% end %>
You can’t perform that action at this time.
0 commit comments