From: Nenad Vujicic Date: Mon, 13 Jan 2025 10:28:11 +0000 (+0100) Subject: Added unit tests for new Note methods X-Git-Tag: live~1^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/11e0444f363a08a08b730a169f56617cd9885315 Added unit tests for new Note methods Added unit tests for new Note methods and updated system tests to use description instead of first comment's body. --- diff --git a/test/models/note_test.rb b/test/models/note_test.rb index 34b16c19d..ba87911e3 100644 --- a/test/models/note_test.rb +++ b/test/models/note_test.rb @@ -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 diff --git a/test/system/report_note_test.rb b/test/system/report_note_test.rb index 79894eb89..c4bcc612d 100644 --- a/test/system/report_note_test.rb +++ b/test/system/report_note_test.rb @@ -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 diff --git a/test/system/report_user_test.rb b/test/system/report_user_test.rb index 7a9e800c8..6ef488e78 100644 --- a/test/system/report_user_test.rb +++ b/test/system/report_user_test.rb @@ -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