From 2455d16a5a975fa5bf75bdb023df61047b055e3d Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 12 Apr 2019 16:08:30 -0700 Subject: Add additional test for sharing templates --- actionview/test/template/resolver_shared_tests.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/test/template/resolver_shared_tests.rb b/actionview/test/template/resolver_shared_tests.rb index ee73ec1922..525b452075 100644 --- a/actionview/test/template/resolver_shared_tests.rb +++ b/actionview/test/template/resolver_shared_tests.rb @@ -110,13 +110,30 @@ module ResolverSharedTests end def test_same_template_from_different_details_is_same_object - with_file "test/hello_world.html.erb", "Hello plain text!" + with_file "test/hello_world.html.erb", "Hello HTML!" a = context.find("hello_world", "test", false, [], locale: [:en]) b = context.find("hello_world", "test", false, [], locale: [:fr]) assert_same a, b end + def test_templates_with_optional_locale_shares_common_object + with_file "test/hello_world.text.erb", "Generic plain text!" + with_file "test/hello_world.fr.text.erb", "Texte en Francais!" + + en = context.find_all("hello_world", "test", false, [], locale: [:en]) + fr = context.find_all("hello_world", "test", false, [], locale: [:fr]) + + assert_equal 1, en.size + assert_equal 2, fr.size + + assert_equal "Generic plain text!", en[0].source + assert_equal "Texte en Francais!", fr[0].source + assert_equal "Generic plain text!", fr[1].source + + assert_same en[0], fr[1] + end + def test_virtual_path_is_preserved_with_dot with_file "test/hello_world.html.erb", "Hello html!" -- cgit v1.2.3