]> git.openstreetmap.org Git - rails.git/commitdiff
Added unit tests for new Note methods
authorNenad Vujicic <nenadus@gmail.com>
Mon, 13 Jan 2025 10:28:11 +0000 (11:28 +0100)
committerNenad Vujicic <nenadus@gmail.com>
Wed, 15 Jan 2025 11:12:56 +0000 (12:12 +0100)
Added unit tests for new Note methods and updated system tests to use description instead of first comment's body.

test/models/note_test.rb
test/system/report_note_test.rb
test/system/report_user_test.rb

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