From c221b5b448569771678279216360460e066095a7 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Wed, 29 May 2019 13:03:54 -0600 Subject: `RenderingHelper` supports rendering objects that `respond_to?` `:render_in` Co-authored-by: Natasha Umer Co-authored-by: Aaron Patterson Co-authored-by: Shawn Allen Co-authored-by: Emily Plummer Co-authored-by: Diana Mounter Co-authored-by: John Hawthorn Co-authored-by: Nathan Herald Co-authored-by: Zaid Zawaideh Co-authored-by: Zach Ahn --- actionview/test/template/render_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'actionview/test/template/render_test.rb') diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index 2235a7816f..c82264a170 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -2,6 +2,8 @@ require "abstract_unit" require "controller/fake_models" +require "test_component" +require "active_model/validations" class TestController < ActionController::Base end @@ -670,6 +672,21 @@ module RenderTestCases def test_render_throws_exception_when_no_extensions_passed_to_register_template_handler_function_call assert_raises(ArgumentError) { ActionView::Template.register_template_handler CustomHandler } end + + def test_render_component + assert_equal( + %(Hello, World! (Inline render)), + @view.render(TestComponent.new(title: "my title")) { "Hello, World!" }.strip + ) + end + + def test_render_component_with_validation_error + error = assert_raises(ActiveModel::ValidationError) do + @view.render(TestComponent.new(title: "my title")).strip + end + + assert_match "Content can't be blank", error.message + end end class CachedViewRenderTest < ActiveSupport::TestCase -- cgit v1.2.3