diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb index b7b4b1aa2..67247505e 100644 --- a/app/views/articles/show.html.erb +++ b/app/views/articles/show.html.erb @@ -131,7 +131,7 @@ • <%= t("views.articles.crossposted.text_html", url: link_to(get_host_without_www(@article.canonical_url || @article.feed_source_url), @article.canonical_url || @article.feed_source_url, style: "color:#1395b8"), on: if @article.crossposted_at - t("views.articles.crossposted.on", + t("views.articles.crossposted.on_html", date: local_date(@article.originally_published_at || @article.published_at, show_year: (@article.originally_published_at || @article.published_at).year != Time.current.year)) else "" diff --git a/config/locales/views/articles/en.yml b/config/locales/views/articles/en.yml index ca938bf8c..7c30b1664 100644 --- a/config/locales/views/articles/en.yml +++ b/config/locales/views/articles/en.yml @@ -75,8 +75,8 @@ en: edit: Click to edit co_authors_html: with %{names} crossposted: - text_html: Originally published at %{url}%{on} - 'on': " on %{date}" + text_html: Originally published at %{url} %{on} + on_html: on %{date} edited: Updated on %{date} edited_html: Updated on %{date} for_org_html: "%{start} for %{end}%{org}" diff --git a/config/locales/views/articles/fr.yml b/config/locales/views/articles/fr.yml index b7d998b9f..61e3c9eb9 100644 --- a/config/locales/views/articles/fr.yml +++ b/config/locales/views/articles/fr.yml @@ -75,8 +75,8 @@ fr: edit: Click to edit co_authors_html: with %{names} crossposted: - text_html: Originally published at %{url}%{on} - 'on': " on %{date}" + text_html: Originally published at %{url} %{on} + on_html: on %{date} edited: Updated on %{date} edited_html: Updated on %{date} for_org_html: "%{start} for %{end}%{org}" diff --git a/spec/views/articles_spec.rb b/spec/views/articles_spec.rb index eaf8a2a05..80316e6c8 100644 --- a/spec/views/articles_spec.rb +++ b/spec/views/articles_spec.rb @@ -64,4 +64,16 @@ RSpec.describe "articles/show", type: :view do expect(rendered).to have_text("example.com") expect(rendered).to have_text("Updated on") end + + it "shows the original publication time for crossposts" do + allow(article1).to receive(:canonical_url).and_return("https://example.com/lamas") + allow(article1).to receive(:crossposted_at).and_return(Time.current) + allow(article1).to receive(:originally_published_at).and_return(Time.zone.at(0)) + render + + # Jan 1, 1970 or Dec 31, 1969, depending on time zone + expected_date = Time.zone.utc_offset.negative? ? "Dec 31, 1969" : "Jan 1, 1970" + expect(rendered).to have_text(expected_date) + expect(rendered).not_to have_text("") + end end