end
end
+ def reportable_dates(reportable)
+ case reportable
+ when DiaryEntry, DiaryComment, Note
+ created_at_time = tag.time l(reportable.created_at.to_datetime, :format => :friendly),
+ :datetime => reportable.created_at.xmlschema
+ updated_at_time = tag.time l(reportable.updated_at.to_datetime, :format => :friendly),
+ :datetime => reportable.updated_at.xmlschema
+ t "issues.helper.reportable_dates.created_on_updated_on_html", :datetime_created => created_at_time, :datetime_updated => updated_at_time
+ when User
+ created_at_time = tag.time l(reportable.created_at.to_datetime, :format => :friendly),
+ :datetime => reportable.created_at.xmlschema
+ t "issues.helper.reportable_dates.created_on_html", :datetime_created => created_at_time
+ end
+ end
+
def open_issues_count
count = Issue.visible_to(current_user).open.limit(Settings.max_issues_count).size
if count >= Settings.max_issues_count
<% content_for :heading do %>
<h1><%= @title %></h1>
-<p><%= @issue.reportable.model_name.human %> : <%= link_to reportable_title(@issue.reportable), reportable_url(@issue.reportable) %></p>
+<p>
+ <%= @issue.reportable.model_name.human %> :
+ <%= link_to reportable_title(@issue.reportable), reportable_url(@issue.reportable) %> :
+ <%= reportable_dates(@issue.reportable) %>
+</p>
<p class="text-body-secondary">
<small>
<%= @issue.assigned_role %>
reportable_title:
diary_comment: "%{entry_title}, comment #%{comment_id}"
note: "Note #%{note_id}"
+ reportable_dates:
+ created_on_html: "created on %{datetime_created}"
+ created_on_updated_on_html: "created on %{datetime_created}, updated on %{datetime_updated}"
reporters:
index:
title: "Issue #%{issue_id} Reporters"
class IssuesHelperTest < ActionView::TestCase
attr_accessor :current_user
+ def test_reportable_dates_note
+ note = create(:note, :created_at => "2020-03-14", :updated_at => "2021-05-16")
+
+ dates = reportable_dates note
+
+ dom_dates = Rails::Dom::Testing.html_document_fragment.parse "<p>#{dates}</p>"
+ assert_dom dom_dates, ":root", "created on 14 March 2020 at 00:00, updated on 16 May 2021 at 00:00"
+ end
+
+ def test_reportable_dates_user
+ user = create(:user, :created_at => "2020-07-18")
+
+ dates = reportable_dates user
+
+ dom_dates = Rails::Dom::Testing.html_document_fragment.parse "<p>#{dates}</p>"
+ assert_dom dom_dates, ":root", "created on 18 July 2020 at 00:00"
+ end
+
def test_issues_count
target_user = create(:user)
self.current_user = create(:moderator_user)