diff --git a/app/presenters/content_item/withdrawable.rb b/app/presenters/content_item/withdrawable.rb index 1df4af1d7..86a0cda2f 100644 --- a/app/presenters/content_item/withdrawable.rb +++ b/app/presenters/content_item/withdrawable.rb @@ -31,11 +31,15 @@ def withdrawal_notice_title end def withdrawal_notice_context - I18n.t("content_item.schema_name.#{schema_name}", count: 1) + I18n.t("content_item.schema_name.#{schema_name}", count: 1, locale: :en) end def withdrawal_notice_time - content_tag(:time, display_date(withdrawal_notice["withdrawn_at"]), datetime: withdrawal_notice["withdrawn_at"]) + content_tag(:time, english_display_date(withdrawal_notice["withdrawn_at"]), datetime: withdrawal_notice["withdrawn_at"]) + end + + def english_display_date(timestamp, format = "%-d %B %Y") + I18n.l(Time.zone.parse(timestamp), format: format, locale: :en) if timestamp end end end diff --git a/test/presenters/content_item/withdrawable_test.rb b/test/presenters/content_item/withdrawable_test.rb index d321c7d6d..5862f60e5 100644 --- a/test/presenters/content_item/withdrawable_test.rb +++ b/test/presenters/content_item/withdrawable_test.rb @@ -4,6 +4,11 @@ class ContentItemWithdrawableTest < ActiveSupport::TestCase def setup @withdrawable = Object.new @withdrawable.extend(ContentItem::Withdrawable) + I18n.locale = :cy + end + + def teardown + I18n.locale = I18n.default_locale end test 'content item is withdrawn' do @@ -60,7 +65,30 @@ def content_item end end - assert_equal @withdrawable.withdrawal_notice_component[:title], "This news article was withdrawn on " + assert_equal @withdrawable.withdrawal_notice_component[:title], "This news article was withdrawn on " assert_equal @withdrawable.withdrawal_notice_component[:description_govspeak], "
It has been superseded by Local area walking and cycling in England: 2014 to 2015.
\\nIt has been superseded by Local area walking and cycling in England: 2014 to 2015.
\n