cross posted articles showing <time> tag (#15224)
* Maybe this is what we need to do? * Undo change to keyword Use the on_html translation in the view, but pass 'on' as a keyword to the template. * remove unused translation Since we only want to use views.articles.crossposted.on.html (and this is only used in the article show template) - remove the unused 'on' key from the translations file. * Add a spec Tested that this fails in main and passes on the branch * Check that the original publication date is shown in the users local And that it's not a <time> tag presented as text * Correct local date selection error If time zone was UTC (i.e. offset from utc was 0) the check for positive? was false, I meant "non-negative" (positive or zero). Invert the test.
This commit is contained in:
parent
44cd136ae0
commit
43adc9f1fb
4 changed files with 17 additions and 5 deletions
|
|
@ -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
|
||||
""
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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("</time>")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue