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
</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>
<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 %>">
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
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
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
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