]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5787' master live
authorTom Hughes <tom@compton.nu>
Mon, 10 Mar 2025 17:19:09 +0000 (17:19 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 10 Mar 2025 17:19:09 +0000 (17:19 +0000)
app/helpers/issues_helper.rb
app/views/issues/show.html.erb
config/locales/en.yml
test/helpers/issues_helper_test.rb

index 55bd0952f7ef27047117953f1010a833a161bfba..64d6dcec57856e3b6c98dfa884acc155ba6fc04a 100644 (file)
@@ -25,6 +25,21 @@ module IssuesHelper
     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
index 74e7c0a4ce1f7793880c542da15d021a743c1ebc..27afb1a6f79d52b1538c44c9a57eeefad2e236fc 100644 (file)
@@ -1,6 +1,10 @@
 <% 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 %>
index ac6834aa055292306bf2f5cd2096e18fd28ac995..e8661906233974faf59781e767ddabcc3c0e96f3 100644 (file)
@@ -1607,6 +1607,9 @@ en:
       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"
index f0b7c884aaefe7ae6969a0e881fe8f20ca6f8626..4ef084f0d8b4afcd05f8b8d5517150b6a6d80ce9 100644 (file)
@@ -3,6 +3,24 @@ require "test_helper"
 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)