From 74979b8e5325a4982bf3af8ba6ce9262cb9010d1 Mon Sep 17 00:00:00 2001 From: Catalina Ilie Date: Wed, 27 Nov 2024 11:38:20 +0000 Subject: [PATCH] Translate correctly Welsh published date Remove the hardcoded locale from `display_date` method --- app/presenters/content_item_presenter.rb | 2 +- test/integration/publication_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index 6b6999ee6..1d1a7187c 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -126,7 +126,7 @@ def voting_is_open? end def display_date(timestamp, format = "%-d %B %Y") - I18n.l(Time.zone.parse(timestamp), format:, locale: "en") if timestamp + I18n.l(Time.zone.parse(timestamp), format:, locale:) if timestamp end def sorted_locales(translations) diff --git a/test/integration/publication_test.rb b/test/integration/publication_test.rb index d24a88667..cb8cfa824 100644 --- a/test/integration/publication_test.rb +++ b/test/integration/publication_test.rb @@ -294,4 +294,18 @@ class PublicationTest < ActionDispatch::IntegrationTest setup_and_visit_content_item("publication-with-featured-attachments", overrides) assert page.has_css?('meta[name="robots"][content="noindex"]', visible: false) end + + test "translates Welsh published date correctly" do + setup_and_visit_content_item("publication", { "locale" => "cy" }) + + assert_has_metadata({ + published: "3 Mai 2016", + from: { + "Environment Agency": "/government/organisations/environment-agency", + "The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles", + }, + }) + + assert_footer_has_published_dates("Cyhoeddwyd ar 3 Mai 2016") + end end