From c7502a4ef83a9b0d480f716476d4af1d49cc5549 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 5 Mar 2023 21:49:19 +0100 Subject: [PATCH] Fix symbol translation test; invoke with start_with? (#83) --- lib/nice_partials/monkey_patch.rb | 2 +- .../translations/_nice_partials_translated_symbol.html.erb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/nice_partials/monkey_patch.rb b/lib/nice_partials/monkey_patch.rb index 9381812..ba57398 100644 --- a/lib/nice_partials/monkey_patch.rb +++ b/lib/nice_partials/monkey_patch.rb @@ -8,7 +8,7 @@ def capture(*, &block) end def t(key, options = {}) - if (prefix = @_nice_partials_t_prefix) && key.to_s.first == '.' + if (prefix = @_nice_partials_t_prefix) && key&.start_with?(".") key = "#{prefix}#{key}" end diff --git a/test/fixtures/translations/_nice_partials_translated_symbol.html.erb b/test/fixtures/translations/_nice_partials_translated_symbol.html.erb index 6293898..32e8556 100644 --- a/test/fixtures/translations/_nice_partials_translated_symbol.html.erb +++ b/test/fixtures/translations/_nice_partials_translated_symbol.html.erb @@ -1,3 +1 @@ -<%= render("basic") do |partial| %> - <%= partial.message.t :message %> -<% end %> +<%= t(:message, scope: "translations.nice_partials_translated_symbol") %>