From 9e15560191a257cff4075f663c39f9f8e4f85c5a Mon Sep 17 00:00:00 2001 From: Marek Kasztelnik Date: Wed, 30 Dec 2020 12:50:03 +0100 Subject: [PATCH] Failing test for lazy translation in partial with block --- .../fixtures/translations/templates/_partial.html.erb | 2 ++ .../templates/partial_lazy_translation.html.erb | 1 + .../templates/partial_lazy_translation_block.html.erb | 2 ++ actionview/test/template/translation_helper_test.rb | 11 ++++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 actionview/test/fixtures/translations/templates/_partial.html.erb create mode 100644 actionview/test/fixtures/translations/templates/partial_lazy_translation.html.erb create mode 100644 actionview/test/fixtures/translations/templates/partial_lazy_translation_block.html.erb diff --git a/actionview/test/fixtures/translations/templates/_partial.html.erb b/actionview/test/fixtures/translations/templates/_partial.html.erb new file mode 100644 index 0000000000..cb17d29c8c --- /dev/null +++ b/actionview/test/fixtures/translations/templates/_partial.html.erb @@ -0,0 +1,2 @@ +<%= t('.foo') %> +<%= yield %> diff --git a/actionview/test/fixtures/translations/templates/partial_lazy_translation.html.erb b/actionview/test/fixtures/translations/templates/partial_lazy_translation.html.erb new file mode 100644 index 0000000000..ca58447e98 --- /dev/null +++ b/actionview/test/fixtures/translations/templates/partial_lazy_translation.html.erb @@ -0,0 +1 @@ +<%= render("translations/templates/partial") %> diff --git a/actionview/test/fixtures/translations/templates/partial_lazy_translation_block.html.erb b/actionview/test/fixtures/translations/templates/partial_lazy_translation_block.html.erb new file mode 100644 index 0000000000..3415d9fa93 --- /dev/null +++ b/actionview/test/fixtures/translations/templates/partial_lazy_translation_block.html.erb @@ -0,0 +1,2 @@ +<%= render("translations/templates/partial") do %> +<% end %> diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index 42f52b91f6..ad8cc8870b 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -23,7 +23,8 @@ class TranslationHelperTest < ActiveSupport::TestCase found_yield_single_argument: { foo: "Foo" }, found_yield_block: { foo: "Foo" }, array: { foo: { bar: "Foo Bar" } }, - default: { foo: "Foo" } + default: { foo: "Foo" }, + partial: { foo: "Partial foo" } }, foo: "Foo", hello: "Hello World", @@ -176,6 +177,14 @@ class TranslationHelperTest < ActiveSupport::TestCase assert_equal "Foo", view.render(template: "translations/templates/found_yield_single_argument").strip end + def test_finds_lazy_translation_scoped_by_partial + assert_equal "Partial foo", view.render(template: "translations/templates/partial_lazy_translation").strip + end + + def test_finds_lazy_translation_scoped_by_partial_with_block + assert_equal "Partial foo", view.render(template: "translations/templates/partial_lazy_translation_block").strip + end + def test_finds_translation_scoped_by_partial_yielding_translation_and_key assert_equal "translations.templates.found_yield_block.foo: Foo", view.render(template: "translations/templates/found_yield_block").strip end