diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb index 6d2664a30..eac87fd23 100644 --- a/app/views/articles/show.html.erb +++ b/app/views/articles/show.html.erb @@ -159,18 +159,19 @@ with <%= @article.co_author_name_and_path.html_safe %> <% end %> - <% if should_show_updated_on?(@article) %> - Updated on - <% elsif should_show_crossposted_on?(@article) %> + <% if should_show_crossposted_on?(@article) %> Originally published at <%= get_host_without_www(@article.canonical_url || @article.feed_source_url) %> <% if @article.crossposted_at %> on - + <%= local_date(@article.originally_published_at || @article.published_at, show_year: (@article.originally_published_at || @article.published_at).year != Time.current.year) %> <% end %> <% end %> + <% if should_show_updated_on?(@article) %> + ・Updated on <%= local_date(@article.edited_at, show_year: @article.edited_at.year != Time.current.year) %> + <% end %> ・<%= @article.reading_time < 1 ? 1 : @article.reading_time %> min read diff --git a/spec/views/articles_spec.rb b/spec/views/articles_spec.rb index df6677cbf..eaf8a2a05 100644 --- a/spec/views/articles_spec.rb +++ b/spec/views/articles_spec.rb @@ -54,4 +54,14 @@ RSpec.describe "articles/show", type: :view do expect(rendered).to have_text("Originally published at") expect(rendered).to have_text("example.com") end + + it "shows a note about the canonical URL after edit" do + allow(article1).to receive(:canonical_url).and_return("https://example.com/lamas") + allow(article1).to receive(:published_at).and_return(Time.zone.at(0)) + allow(article1).to receive(:edited_at).and_return(Time.current) + render + expect(rendered).to have_text("Originally published at") + expect(rendered).to have_text("example.com") + expect(rendered).to have_text("Updated on") + end end