From c6c1afd3d46ad7b5e3e3402e84d7edc35841bddb Mon Sep 17 00:00:00 2001 From: LowLevel Date: Mon, 18 Aug 2025 23:57:00 +0200 Subject: [PATCH 01/12] Add failing test for relative translation in partial block --- ...translation_partial_parent_component.html.erb | 3 +++ ...ative_translation_partial_parent_component.rb | 4 ++++ test/sandbox/app/views/shared/_partial.html.erb | 1 + test/sandbox/config/locales/en.yml | 7 +++++++ ...elative_translation_partial_component_test.rb | 16 ++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 test/sandbox/app/components/relative_translation_partial_parent_component.html.erb create mode 100644 test/sandbox/app/components/relative_translation_partial_parent_component.rb create mode 100644 test/sandbox/app/views/shared/_partial.html.erb create mode 100644 test/sandbox/test/components/relative_translation_partial_component_test.rb diff --git a/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb b/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb new file mode 100644 index 000000000..926f4e21e --- /dev/null +++ b/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb @@ -0,0 +1,3 @@ +<%= render "shared/partial" do %> + <%= t(".title") %> +<% end %> \ No newline at end of file diff --git a/test/sandbox/app/components/relative_translation_partial_parent_component.rb b/test/sandbox/app/components/relative_translation_partial_parent_component.rb new file mode 100644 index 000000000..f8caad8a1 --- /dev/null +++ b/test/sandbox/app/components/relative_translation_partial_parent_component.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class RelativeTranslationPartialParentComponent < ViewComponent::Base +end diff --git a/test/sandbox/app/views/shared/_partial.html.erb b/test/sandbox/app/views/shared/_partial.html.erb new file mode 100644 index 000000000..37f0bddbd --- /dev/null +++ b/test/sandbox/app/views/shared/_partial.html.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index 7a4c5f897..3df97f601 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -24,3 +24,10 @@ en: my_component: message: "OH NO! (you shouldn't see me)" + + test_component: + title: "Test Component Title" + subtitle: "Test Component Subtitle" + shared: + partial: + title: "Partial Title" \ No newline at end of file diff --git a/test/sandbox/test/components/relative_translation_partial_component_test.rb b/test/sandbox/test/components/relative_translation_partial_component_test.rb new file mode 100644 index 000000000..f0601efa6 --- /dev/null +++ b/test/sandbox/test/components/relative_translation_partial_component_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "test_helper" + +class RelativeTranslationPartialComponentTest < ViewComponent::TestCase + def test_relative_translation_in_partial_block + render_inline(RelativeTranslationPartialParentComponent.new) + + # This should pass if Rails resolves the translation key relative to the caller's path, + # but currently fails because it resolves relative to the partial's path. + assert_text "Test Component Title" + + # This assertion documents the current (incorrect) behavior. + assert_no_text "Partial Title" + end +end From 89fe8d4161f0187ebe02fbdf26491dfe236185c3 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Tue, 19 Aug 2025 00:18:04 +0200 Subject: [PATCH 02/12] Add changelog --- docs/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 38c662010..0d724bc5b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -39,6 +39,9 @@ nav_order: 6 * Declare `actionview` as a `view_component` gem dependency. *Michal Cichra* +* Add test documenting current behavior for resolving relative translation keys in partial blocks. The test expects translation keys to resolve relative to the caller's path, but currently they resolve relative to the partial's path, which is incorrect. + + *Oussama Hilal* ## 4.0.2 From ffbfacf242f85acbfd37ee6837d8ed0f79f52ba8 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Tue, 19 Aug 2025 00:22:29 +0200 Subject: [PATCH 03/12] Remove comments in test --- .../relative_translation_partial_component_test.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/sandbox/test/components/relative_translation_partial_component_test.rb b/test/sandbox/test/components/relative_translation_partial_component_test.rb index f0601efa6..adeaa0e6b 100644 --- a/test/sandbox/test/components/relative_translation_partial_component_test.rb +++ b/test/sandbox/test/components/relative_translation_partial_component_test.rb @@ -6,11 +6,6 @@ class RelativeTranslationPartialComponentTest < ViewComponent::TestCase def test_relative_translation_in_partial_block render_inline(RelativeTranslationPartialParentComponent.new) - # This should pass if Rails resolves the translation key relative to the caller's path, - # but currently fails because it resolves relative to the partial's path. assert_text "Test Component Title" - - # This assertion documents the current (incorrect) behavior. - assert_no_text "Partial Title" end end From 20265e6ad419f690a124a9c92f6c9f5722d548e6 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Tue, 19 Aug 2025 00:23:39 +0200 Subject: [PATCH 04/12] Remove subtitle translation --- test/sandbox/config/locales/en.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index 3df97f601..add531ef3 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -27,7 +27,6 @@ en: test_component: title: "Test Component Title" - subtitle: "Test Component Subtitle" shared: partial: title: "Partial Title" \ No newline at end of file From 59ab0df159b1ff5af8267b7bd0b4653abe2177a7 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Tue, 19 Aug 2025 00:25:44 +0200 Subject: [PATCH 05/12] Remove quotation marks in translations --- test/sandbox/config/locales/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index add531ef3..1a9e1c30e 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -26,7 +26,7 @@ en: message: "OH NO! (you shouldn't see me)" test_component: - title: "Test Component Title" + title: Test Component Title shared: partial: - title: "Partial Title" \ No newline at end of file + title: Partial Title \ No newline at end of file From 4cd61d12b855955c093c9ab2a540d5ae2ec47e71 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Tue, 19 Aug 2025 00:36:49 +0200 Subject: [PATCH 06/12] Add correct translation key of component --- test/sandbox/config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index 1a9e1c30e..b80c75b99 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -25,7 +25,7 @@ en: my_component: message: "OH NO! (you shouldn't see me)" - test_component: + relative_translation_partial_parent_component: title: Test Component Title shared: partial: From 666f5fd690c8efc4bc320d0c8e7f51f24322a8e0 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Wed, 27 Aug 2025 11:53:59 +0200 Subject: [PATCH 07/12] Fix erb_lint error --- .../relative_translation_partial_parent_component.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb b/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb index 926f4e21e..e862ab350 100644 --- a/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb +++ b/test/sandbox/app/components/relative_translation_partial_parent_component.html.erb @@ -1,3 +1,3 @@ <%= render "shared/partial" do %> <%= t(".title") %> -<% end %> \ No newline at end of file +<% end %> From b48bb9bf933429577030aeaff47e2255d7abbfd4 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Wed, 27 Aug 2025 12:03:42 +0200 Subject: [PATCH 08/12] Remove rails_main gemfile lock --- gemfiles/rails_main.gemfile.lock | 462 ------------------------------- 1 file changed, 462 deletions(-) delete mode 100644 gemfiles/rails_main.gemfile.lock diff --git a/gemfiles/rails_main.gemfile.lock b/gemfiles/rails_main.gemfile.lock deleted file mode 100644 index cf88b1240..000000000 --- a/gemfiles/rails_main.gemfile.lock +++ /dev/null @@ -1,462 +0,0 @@ -GIT - remote: https://github.com/rack/rack - revision: 8a4475a9f416a72e5b02bd7817e4a8ed684f29b0 - ref: 8a4475a9f416a72e5b02bd7817e4a8ed684f29b0 - specs: - rack (3.1.1) - -GIT - remote: https://github.com/rails/rails.git - revision: e66cd375ff553578533a6d2232c3f4ecb154933f - branch: main - specs: - actioncable (8.2.0.alpha) - actionpack (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (8.2.0.alpha) - actionpack (= 8.2.0.alpha) - activejob (= 8.2.0.alpha) - activerecord (= 8.2.0.alpha) - activestorage (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - mail (>= 2.8.0) - actionmailer (8.2.0.alpha) - actionpack (= 8.2.0.alpha) - actionview (= 8.2.0.alpha) - activejob (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - mail (>= 2.8.0) - rails-dom-testing (~> 2.2) - actionpack (8.2.0.alpha) - actionview (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - nokogiri (>= 1.8.5) - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - useragent (~> 0.16) - actiontext (8.2.0.alpha) - action_text-trix (~> 2.1.15) - actionpack (= 8.2.0.alpha) - activerecord (= 8.2.0.alpha) - activestorage (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - globalid (>= 0.3.6) - activemodel (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - activerecord (8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - timeout (>= 0.4.0) - activestorage (8.2.0.alpha) - actionpack (= 8.2.0.alpha) - activejob (= 8.2.0.alpha) - activerecord (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - marcel (~> 1.0) - activesupport (8.2.0.alpha) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - rails (8.2.0.alpha) - actioncable (= 8.2.0.alpha) - actionmailbox (= 8.2.0.alpha) - actionmailer (= 8.2.0.alpha) - actionpack (= 8.2.0.alpha) - actiontext (= 8.2.0.alpha) - actionview (= 8.2.0.alpha) - activejob (= 8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activerecord (= 8.2.0.alpha) - activestorage (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - bundler (>= 1.15.0) - railties (= 8.2.0.alpha) - railties (8.2.0.alpha) - actionpack (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - irb (~> 1.13) - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - tsort (>= 0.2) - zeitwerk (~> 2.6) - -PATH - remote: .. - specs: - view_component (4.1.0) - actionview (>= 7.1.0, < 8.2) - activesupport (>= 7.1.0, < 8.2) - concurrent-ruby (~> 1) - -GEM - remote: https://rubygems.org/ - specs: - action_text-trix (2.1.15) - railties - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - allocation_stats (0.1.5) - ansi (1.5.0) - appraisal (2.5.0) - bundler - rake - thor (>= 0.14.0) - appraisal-run (1.0.0) - ast (2.4.3) - base64 (0.3.0) - benchmark-ips (2.14.0) - better_html (2.2.0) - actionview (>= 7.0) - activesupport (>= 7.0) - ast (~> 2.0) - erubi (~> 1.4) - parser (>= 2.4) - smart_properties - bigdecimal (3.3.1) - builder (3.3.0) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - concurrent-ruby (1.3.5) - connection_pool (2.5.4) - crass (1.0.6) - cuprite (0.17) - capybara (~> 3.0) - ferrum (~> 0.17.0) - date (3.4.1) - diff-lcs (1.6.2) - docile (1.4.1) - drb (2.2.3) - dry-initializer (3.2.0) - erb (5.1.1) - erb_lint (0.9.0) - activesupport - better_html (>= 2.0.1) - parser (>= 2.7.1.4) - rainbow - rubocop (>= 1) - smart_properties - erubi (1.13.1) - ferrum (0.17.1) - addressable (~> 2.5) - base64 (~> 0.2) - concurrent-ruby (~> 1.1) - webrick (~> 1.7) - websocket-driver (~> 0.7) - globalid (1.3.0) - activesupport (>= 6.1) - haml (6.3.0) - temple (>= 0.8.2) - thor - tilt - i18n (1.14.7) - concurrent-ruby (~> 1.0) - io-console (0.8.1) - irb (1.15.2) - pp (>= 0.6.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.14.1) - actionview (>= 7.0.0) - activesupport (>= 7.0.0) - json (2.15.1) - language_server-protocol (3.17.0.5) - lint_roller (1.1.0) - logger (1.7.0) - loofah (2.24.1) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - m (1.6.2) - method_source (>= 0.6.7) - rake (>= 0.9.2.2) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.1.0) - matrix (0.4.3) - method_source (1.1.0) - mini_mime (1.1.5) - minitest (5.26.0) - net-imap (0.5.12) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.1) - net-protocol - nio4r (2.7.4) - nokogiri (1.18.10-aarch64-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.10-aarch64-linux-musl) - racc (~> 1.4) - nokogiri (1.18.10-arm-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.10-arm-linux-musl) - racc (~> 1.4) - nokogiri (1.18.10-arm64-darwin) - racc (~> 1.4) - nokogiri (1.18.10-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-gnu) - racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-musl) - racc (~> 1.4) - parallel (1.27.0) - parser (3.3.9.0) - ast (~> 2.4.1) - racc - pp (0.6.3) - prettyprint - prettyprint (0.2.0) - prism (1.6.0) - propshaft (1.3.1) - actionpack (>= 7.0.0) - activesupport (>= 7.0.0) - rack - psych (5.2.6) - date - stringio - public_suffix (6.0.2) - puma (6.6.1) - nio4r (~> 2.0) - racc (1.8.1) - rack-session (2.1.1) - base64 (>= 0.1.0) - rack (>= 3.0.0) - rack-test (2.2.0) - rack (>= 1.3) - rackup (2.2.1) - rack (>= 3) - rails-dom-testing (2.3.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) - nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - rainbow (3.1.1) - rake (13.3.0) - rdoc (6.15.0) - erb - psych (>= 4.0.0) - tsort - redis (5.4.1) - redis-client (>= 0.22.0) - redis-client (0.26.1) - connection_pool - regexp_parser (2.11.3) - reline (0.6.2) - io-console (~> 0.5) - rexml (3.4.4) - rspec-core (3.13.6) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.5) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.6) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-rails (8.0.2) - actionpack (>= 7.2) - activesupport (>= 7.2) - railties (>= 7.2) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) - rspec-support (3.13.6) - rubocop (1.80.2) - json (~> 2.3) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.1.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.46.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.47.1) - parser (>= 3.3.7.2) - prism (~> 1.4) - rubocop-md (2.0.3) - lint_roller (~> 1.1) - rubocop (>= 1.72.1) - rubocop-performance (1.25.0) - lint_roller (~> 1.1) - rubocop (>= 1.75.0, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) - ruby-progressbar (1.13.0) - rubyzip (3.2.0) - securerandom (0.4.1) - selenium-webdriver (4.37.0) - base64 (~> 0.2) - logger (~> 1.4) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 4.0) - websocket (~> 1.0) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-console (0.9.4) - ansi - simplecov - terminal-table - simplecov-html (0.13.2) - simplecov_json_formatter (0.1.4) - slim (5.2.1) - temple (~> 0.10.0) - tilt (>= 2.1.0) - smart_properties (1.17.0) - sprockets (4.2.2) - concurrent-ruby (~> 1.0) - logger - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - standard (1.51.1) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.80.2) - standard-custom (~> 1.0.0) - standard-performance (~> 1.8) - standard-custom (1.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.50) - standard-performance (1.8.0) - lint_roller (~> 1.1) - rubocop-performance (~> 1.25.0) - stringio (3.1.7) - tailwindcss-rails (4.3.0) - railties (>= 7.0.0) - tailwindcss-ruby (~> 4.0) - tailwindcss-ruby (4.1.13) - tailwindcss-ruby (4.1.13-aarch64-linux-gnu) - tailwindcss-ruby (4.1.13-aarch64-linux-musl) - tailwindcss-ruby (4.1.13-arm64-darwin) - tailwindcss-ruby (4.1.13-x86_64-darwin) - tailwindcss-ruby (4.1.13-x86_64-linux-gnu) - tailwindcss-ruby (4.1.13-x86_64-linux-musl) - temple (0.10.4) - terminal-table (4.0.0) - unicode-display_width (>= 1.1.1, < 4) - thor (1.4.0) - tilt (2.6.1) - timeout (0.4.3) - tsort (0.2.0) - turbo-rails (2.0.17) - actionpack (>= 7.1.0) - railties (>= 7.1.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (3.2.0) - unicode-emoji (~> 4.1) - unicode-emoji (4.1.0) - uri (1.0.4) - useragent (0.16.11) - warning (1.5.0) - webrick (1.9.1) - websocket (1.2.11) - websocket-driver (0.8.0) - base64 - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - yard (0.9.37) - yard-activesupport-concern (0.0.1) - yard (>= 0.8) - zeitwerk (2.7.3) - -PLATFORMS - aarch64-linux-gnu - aarch64-linux-musl - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86_64-darwin - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - allocation_stats - appraisal (~> 2) - appraisal-run (~> 1.0) - benchmark-ips (~> 2) - better_html - bundler (~> 2) - capybara (~> 3) - cuprite - dry-initializer - erb_lint - haml (~> 6) - jbuilder (~> 2) - m (~> 1) - method_source (~> 1) - minitest (~> 5) - propshaft (~> 1) - puma (~> 6) - rack! - rails! - rails-dom-testing (~> 2.3.0) - rake (~> 13) - redis - rspec-rails (~> 8) - rubocop-md (~> 2) - selenium-webdriver (~> 4) - simplecov (< 1) - simplecov-console (< 1) - slim (~> 5) - sprockets-rails (~> 3) - standard (~> 1) - tailwindcss-rails (~> 4) - turbo-rails (~> 2) - view_component! - warning - yard (< 1) - yard-activesupport-concern (< 1) - -RUBY VERSION - ruby 3.4.7p58 - -BUNDLED WITH - 2.6.9 From 3ce83caad06d2729d44a4965d7ab7408222b55e6 Mon Sep 17 00:00:00 2001 From: LowLevel Date: Wed, 27 Aug 2025 12:04:32 +0200 Subject: [PATCH 09/12] Hopefully fix trailing whitespace lint issue --- test/sandbox/config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index b80c75b99..764a6a46c 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -29,4 +29,4 @@ en: title: Test Component Title shared: partial: - title: Partial Title \ No newline at end of file + title: Partial Title From 0b3bea30ecab8a9470742f858ba175c9b368e277 Mon Sep 17 00:00:00 2001 From: Ackermann Date: Sat, 8 Nov 2025 14:30:19 +0100 Subject: [PATCH 10/12] Adjust component names, changelog text and text assertion --- docs/CHANGELOG.md | 7 ++++--- .../relative_translation_partial_block_component.html.erb | 3 +++ .../relative_translation_partial_block_component.rb | 4 ++++ test/sandbox/config/locales/en.yml | 2 +- .../relative_translation_partial_component_test.rb | 6 +++--- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 test/sandbox/app/components/relative_translation_partial_block_component.html.erb create mode 100644 test/sandbox/app/components/relative_translation_partial_block_component.rb diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0d724bc5b..218793afe 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 6 ## main +* Add test to document the current behavior for resolving relative translation keys within partial blocks. When rendering a partial, relative translation keys are resolved relative to the partial’s own path rather than the caller’s path. This test ensures that this behavior remains consistent. + + *Oussama Hilal* + * Add Consultport to list of companies using ViewComponent. *Sebastian Nepote* @@ -39,9 +43,6 @@ nav_order: 6 * Declare `actionview` as a `view_component` gem dependency. *Michal Cichra* -* Add test documenting current behavior for resolving relative translation keys in partial blocks. The test expects translation keys to resolve relative to the caller's path, but currently they resolve relative to the partial's path, which is incorrect. - - *Oussama Hilal* ## 4.0.2 diff --git a/test/sandbox/app/components/relative_translation_partial_block_component.html.erb b/test/sandbox/app/components/relative_translation_partial_block_component.html.erb new file mode 100644 index 000000000..e862ab350 --- /dev/null +++ b/test/sandbox/app/components/relative_translation_partial_block_component.html.erb @@ -0,0 +1,3 @@ +<%= render "shared/partial" do %> + <%= t(".title") %> +<% end %> diff --git a/test/sandbox/app/components/relative_translation_partial_block_component.rb b/test/sandbox/app/components/relative_translation_partial_block_component.rb new file mode 100644 index 000000000..c8a627c0a --- /dev/null +++ b/test/sandbox/app/components/relative_translation_partial_block_component.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class RelativeTranslationPartialBlockComponent < ViewComponent::Base +end diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index 764a6a46c..e820ddb0e 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -25,7 +25,7 @@ en: my_component: message: "OH NO! (you shouldn't see me)" - relative_translation_partial_parent_component: + relative_translation_partial_block_component: title: Test Component Title shared: partial: diff --git a/test/sandbox/test/components/relative_translation_partial_component_test.rb b/test/sandbox/test/components/relative_translation_partial_component_test.rb index adeaa0e6b..0054b6b89 100644 --- a/test/sandbox/test/components/relative_translation_partial_component_test.rb +++ b/test/sandbox/test/components/relative_translation_partial_component_test.rb @@ -2,10 +2,10 @@ require "test_helper" -class RelativeTranslationPartialComponentTest < ViewComponent::TestCase +class RelativeTranslationPartialBlockComponentTest < ViewComponent::TestCase def test_relative_translation_in_partial_block - render_inline(RelativeTranslationPartialParentComponent.new) + render_inline(RelativeTranslationPartialBlockComponent.new) - assert_text "Test Component Title" + assert_text "Partial Title" end end From 3b1497fee27509226b17279b1f370bce545cfd1f Mon Sep 17 00:00:00 2001 From: Ackermann Date: Sat, 8 Nov 2025 14:37:56 +0100 Subject: [PATCH 11/12] Add accidentally removed gemfile lock --- gemfiles/rails_main.gemfile.lock | 462 +++++++++++++++++++++++++++++++ 1 file changed, 462 insertions(+) create mode 100644 gemfiles/rails_main.gemfile.lock diff --git a/gemfiles/rails_main.gemfile.lock b/gemfiles/rails_main.gemfile.lock new file mode 100644 index 000000000..cf88b1240 --- /dev/null +++ b/gemfiles/rails_main.gemfile.lock @@ -0,0 +1,462 @@ +GIT + remote: https://github.com/rack/rack + revision: 8a4475a9f416a72e5b02bd7817e4a8ed684f29b0 + ref: 8a4475a9f416a72e5b02bd7817e4a8ed684f29b0 + specs: + rack (3.1.1) + +GIT + remote: https://github.com/rails/rails.git + revision: e66cd375ff553578533a6d2232c3f4ecb154933f + branch: main + specs: + actioncable (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + mail (>= 2.8.0) + actionmailer (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + actionview (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.2.0.alpha) + actionview (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.2.0.alpha) + action_text-trix (~> 2.1.15) + actionpack (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.2.0.alpha) + activesupport (= 8.2.0.alpha) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.2.0.alpha) + activesupport (= 8.2.0.alpha) + globalid (>= 0.3.6) + activemodel (8.2.0.alpha) + activesupport (= 8.2.0.alpha) + activerecord (8.2.0.alpha) + activemodel (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + timeout (>= 0.4.0) + activestorage (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + marcel (~> 1.0) + activesupport (8.2.0.alpha) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + rails (8.2.0.alpha) + actioncable (= 8.2.0.alpha) + actionmailbox (= 8.2.0.alpha) + actionmailer (= 8.2.0.alpha) + actionpack (= 8.2.0.alpha) + actiontext (= 8.2.0.alpha) + actionview (= 8.2.0.alpha) + activejob (= 8.2.0.alpha) + activemodel (= 8.2.0.alpha) + activerecord (= 8.2.0.alpha) + activestorage (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + bundler (>= 1.15.0) + railties (= 8.2.0.alpha) + railties (8.2.0.alpha) + actionpack (= 8.2.0.alpha) + activesupport (= 8.2.0.alpha) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + +PATH + remote: .. + specs: + view_component (4.1.0) + actionview (>= 7.1.0, < 8.2) + activesupport (>= 7.1.0, < 8.2) + concurrent-ruby (~> 1) + +GEM + remote: https://rubygems.org/ + specs: + action_text-trix (2.1.15) + railties + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + allocation_stats (0.1.5) + ansi (1.5.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + appraisal-run (1.0.0) + ast (2.4.3) + base64 (0.3.0) + benchmark-ips (2.14.0) + better_html (2.2.0) + actionview (>= 7.0) + activesupport (>= 7.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties + bigdecimal (3.3.1) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.3.5) + connection_pool (2.5.4) + crass (1.0.6) + cuprite (0.17) + capybara (~> 3.0) + ferrum (~> 0.17.0) + date (3.4.1) + diff-lcs (1.6.2) + docile (1.4.1) + drb (2.2.3) + dry-initializer (3.2.0) + erb (5.1.1) + erb_lint (0.9.0) + activesupport + better_html (>= 2.0.1) + parser (>= 2.7.1.4) + rainbow + rubocop (>= 1) + smart_properties + erubi (1.13.1) + ferrum (0.17.1) + addressable (~> 2.5) + base64 (~> 0.2) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + globalid (1.3.0) + activesupport (>= 6.1) + haml (6.3.0) + temple (>= 0.8.2) + thor + tilt + i18n (1.14.7) + concurrent-ruby (~> 1.0) + io-console (0.8.1) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.14.1) + actionview (>= 7.0.0) + activesupport (>= 7.0.0) + json (2.15.1) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.24.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + m (1.6.2) + method_source (>= 0.6.7) + rake (>= 0.9.2.2) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.1.0) + matrix (0.4.3) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.26.0) + net-imap (0.5.12) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.10-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.10-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.10-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-musl) + racc (~> 1.4) + parallel (1.27.0) + parser (3.3.9.0) + ast (~> 2.4.1) + racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.6.0) + propshaft (1.3.1) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + psych (5.2.6) + date + stringio + public_suffix (6.0.2) + puma (6.6.1) + nio4r (~> 2.0) + racc (1.8.1) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.2.1) + rack (>= 3) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rainbow (3.1.1) + rake (13.3.0) + rdoc (6.15.0) + erb + psych (>= 4.0.0) + tsort + redis (5.4.1) + redis-client (>= 0.22.0) + redis-client (0.26.1) + connection_pool + regexp_parser (2.11.3) + reline (0.6.2) + io-console (~> 0.5) + rexml (3.4.4) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (8.0.2) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.6) + rubocop (1.80.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-md (2.0.3) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-performance (1.25.0) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) + ruby-progressbar (1.13.0) + rubyzip (3.2.0) + securerandom (0.4.1) + selenium-webdriver (4.37.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 4.0) + websocket (~> 1.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-console (0.9.4) + ansi + simplecov + terminal-table + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) + slim (5.2.1) + temple (~> 0.10.0) + tilt (>= 2.1.0) + smart_properties (1.17.0) + sprockets (4.2.2) + concurrent-ruby (~> 1.0) + logger + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + standard (1.51.1) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.80.2) + standard-custom (~> 1.0.0) + standard-performance (~> 1.8) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.8.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.25.0) + stringio (3.1.7) + tailwindcss-rails (4.3.0) + railties (>= 7.0.0) + tailwindcss-ruby (~> 4.0) + tailwindcss-ruby (4.1.13) + tailwindcss-ruby (4.1.13-aarch64-linux-gnu) + tailwindcss-ruby (4.1.13-aarch64-linux-musl) + tailwindcss-ruby (4.1.13-arm64-darwin) + tailwindcss-ruby (4.1.13-x86_64-darwin) + tailwindcss-ruby (4.1.13-x86_64-linux-gnu) + tailwindcss-ruby (4.1.13-x86_64-linux-musl) + temple (0.10.4) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + thor (1.4.0) + tilt (2.6.1) + timeout (0.4.3) + tsort (0.2.0) + turbo-rails (2.0.17) + actionpack (>= 7.1.0) + railties (>= 7.1.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uri (1.0.4) + useragent (0.16.11) + warning (1.5.0) + webrick (1.9.1) + websocket (1.2.11) + websocket-driver (0.8.0) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + yard-activesupport-concern (0.0.1) + yard (>= 0.8) + zeitwerk (2.7.3) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + allocation_stats + appraisal (~> 2) + appraisal-run (~> 1.0) + benchmark-ips (~> 2) + better_html + bundler (~> 2) + capybara (~> 3) + cuprite + dry-initializer + erb_lint + haml (~> 6) + jbuilder (~> 2) + m (~> 1) + method_source (~> 1) + minitest (~> 5) + propshaft (~> 1) + puma (~> 6) + rack! + rails! + rails-dom-testing (~> 2.3.0) + rake (~> 13) + redis + rspec-rails (~> 8) + rubocop-md (~> 2) + selenium-webdriver (~> 4) + simplecov (< 1) + simplecov-console (< 1) + slim (~> 5) + sprockets-rails (~> 3) + standard (~> 1) + tailwindcss-rails (~> 4) + turbo-rails (~> 2) + view_component! + warning + yard (< 1) + yard-activesupport-concern (< 1) + +RUBY VERSION + ruby 3.4.7p58 + +BUNDLED WITH + 2.6.9 From 6c346c6c414a07e463f73d96c2228f111e9386fb Mon Sep 17 00:00:00 2001 From: Ackermann Date: Sat, 8 Nov 2025 15:02:13 +0100 Subject: [PATCH 12/12] Remove not needed component translation --- test/sandbox/config/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/sandbox/config/locales/en.yml b/test/sandbox/config/locales/en.yml index e820ddb0e..de3fc45d9 100644 --- a/test/sandbox/config/locales/en.yml +++ b/test/sandbox/config/locales/en.yml @@ -25,8 +25,6 @@ en: my_component: message: "OH NO! (you shouldn't see me)" - relative_translation_partial_block_component: - title: Test Component Title shared: partial: title: Partial Title