diff options
Diffstat (limited to 'actionview/test/template/render_test.rb')
-rw-r--r-- | actionview/test/template/render_test.rb | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index f0b5d7d95e..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 @@ -33,6 +35,11 @@ module RenderTestCases assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort end + def teardown + I18n.reload! + ActionController::Base.view_paths.map(&:clear_cache) + end + def test_implicit_format_comes_from_parent_template rendered_templates = JSON.parse(@controller_view.render(template: "test/mixing_formats")) assert_equal({ "format" => "HTML", @@ -665,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( + %(<span title="my title">Hello, World! (Inline render)</span>), + @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 @@ -677,11 +699,6 @@ class CachedViewRenderTest < ActiveSupport::TestCase assert_equal ActionView::OptimizedFileSystemResolver, view_paths.first.class setup_view(view_paths) end - - def teardown - GC.start - I18n.reload! - end end class LazyViewRenderTest < ActiveSupport::TestCase @@ -697,11 +714,6 @@ class LazyViewRenderTest < ActiveSupport::TestCase setup_view(view_paths) end - def teardown - GC.start - I18n.reload! - end - def test_render_utf8_template_with_magic_comment with_external_encoding Encoding::ASCII_8BIT do result = @view.render(template: "test/utf8_magic", formats: [:html], layouts: "layouts/yield") @@ -758,10 +770,6 @@ class CachedCollectionViewRenderTest < ActiveSupport::TestCase setup_view(view_paths) end - teardown do - I18n.reload! - end - test "template body written to cache" do customer = Customer.new("david", 1) key = cache_key(customer, "test/_customer") |