]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5494'
authorTom Hughes <tom@compton.nu>
Thu, 16 Jan 2025 18:35:36 +0000 (18:35 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 16 Jan 2025 18:35:36 +0000 (18:35 +0000)
app/models/note.rb
app/views/notes/index.html.erb
app/views/notes/show.html.erb
test/models/note_test.rb
test/system/report_note_test.rb
test/system/report_user_test.rb

index 6d8ca078fa42e1d12e1652e3795a1e32caf02c26..d23f458e51f6ca80a7f6aea61363353ee7724fd9 100644 (file)
@@ -82,12 +82,22 @@ class Note < ApplicationRecord
     closed_at + DEFAULT_FRESHLY_CLOSED_LIMIT
   end
 
-  # Return the author object, derived from the first comment
+  # Return the note's description, derived from the first comment
+  def description
+    comments.first.body
+  end
+
+  # Return the note's author object, derived from the first comment
   def author
     comments.first.author
   end
 
-  # Return the author IP address, derived from the first comment
+  # Return the note's author ID, derived from the first comment
+  def author_id
+    comments.first.author_id
+  end
+
+  # Return the note's author IP address, derived from the first comment
   def author_ip
     comments.first.author_ip
   end
index c883126658e7c69b7cb278f4d9724c35f3d12bdd..f805a10402b413aa295875010a051b7ecbbef76f 100644 (file)
@@ -48,7 +48,7 @@
       </td>
       <td><%= link_to note.id, note %></td>
       <td><%= note_author(note.author) %></td>
-      <td><%= note.comments.first.body.to_html %></td>
+      <td><%= note.description.to_html %></td>
       <td><%= friendly_date_ago(note.created_at) %></td>
       <td><%= friendly_date_ago(note.updated_at) %></td>
     </tr>
index d17612e2929be2a70b315dc78e955e2da56c03ef..a320240488e716224a8908bbed5b612988e7907e 100644 (file)
@@ -5,7 +5,7 @@
 <div>
   <h4><%= t(".description") %></h4>
   <div class="overflow-hidden ms-2">
-    <%= h(@note_comments.first.body.to_html) %>
+    <%= h(@note.description.to_html) %>
   </div>
 
   <div class="details" data-coordinates="<%= @note.lat %>,<%= @note.lon %>" data-status="<%= @note.status %>">
index 34b16c19d5e113a197ee4ff8ba7b4b29ff600256..ba87911e33a8d79be67e2793958bdb5f8c20290b 100644 (file)
@@ -47,6 +47,15 @@ class NoteTest < ActiveSupport::TestCase
     assert_not_predicate create(:note, :status => "open", :closed_at => nil), :closed?
   end
 
+  def test_description
+    comment = create(:note_comment)
+    assert_equal comment.body, comment.note.description
+
+    user = create(:user)
+    comment = create(:note_comment, :author => user)
+    assert_equal comment.body, comment.note.description
+  end
+
   def test_author
     comment = create(:note_comment)
     assert_nil comment.note.author
@@ -56,6 +65,15 @@ class NoteTest < ActiveSupport::TestCase
     assert_equal user, comment.note.author
   end
 
+  def test_author_id
+    comment = create(:note_comment)
+    assert_nil comment.note.author_id
+
+    user = create(:user)
+    comment = create(:note_comment, :author => user)
+    assert_equal user.id, comment.note.author_id
+  end
+
   def test_author_ip
     comment = create(:note_comment)
     assert_nil comment.note.author_ip
index 79894eb897d4a514e3ebb94b5a89a680a1bcedf5..c4bcc612d61751264908e22641422d44d3c60862 100644 (file)
@@ -4,7 +4,7 @@ class ReportNoteTest < ApplicationSystemTestCase
   def test_no_link_when_not_logged_in
     note = create(:note_with_comments)
     visit note_path(note)
-    assert_content note.comments.first.body
+    assert_content note.description
 
     assert_no_content I18n.t("notes.show.report")
   end
index 7a9e800c8c0da99ebf7351d6a863d9c8cec8ba7a..6ef488e788a2387e92f1501d837c513742ebfda9 100644 (file)
@@ -4,7 +4,7 @@ class ReportUserTest < ApplicationSystemTestCase
   def test_no_link_when_not_logged_in
     note = create(:note_with_comments)
     visit note_path(note)
-    assert_content note.comments.first.body
+    assert_content note.description
 
     assert_no_content I18n.t("users.show.report")
   end