Skip to content

Commit 8b66580

Browse files
authored
add test case for compatibility with custom AV::Base sublasses (#2304)
1 parent d629a83 commit 8b66580

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/sandbox/test/rendering_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,4 +1260,27 @@ def test_render_anonymous_component_without_template
12601260
render_inline(mock_component.new)
12611261
end
12621262
end
1263+
1264+
class CustomView < ActionView::Base
1265+
def hi
1266+
"Hi!"
1267+
end
1268+
end
1269+
1270+
class GreetingComponent < ViewComponent::Base
1271+
def call
1272+
# Calling `hi` directly doesn't work because ViewComponent::Base doesn't
1273+
# inherit from ActionView::Base:
1274+
#
1275+
# hi # raises: undefined method `hi' for #<GreetingComponent....
1276+
#
1277+
helpers.hi
1278+
end
1279+
end
1280+
1281+
def test_custom_base
1282+
custom_view = CustomView.with_empty_template_cache.with_view_paths []
1283+
1284+
assert_includes("Hi!", custom_view.render(GreetingComponent.new))
1285+
end
12631286
end

0 commit comments

Comments
 (0)