Put issue comments through kramdown formatter
On issue comments (which only admins can create or see), put the `body` text through kramdown formatting.
This commit is contained in:
parent
e204e1d178
commit
3ca8b63643
3 changed files with 10 additions and 1 deletions
|
@ -25,4 +25,8 @@ class IssueComment < ApplicationRecord
|
|||
belongs_to :user
|
||||
|
||||
validates :body, :presence => true, :characters => true
|
||||
|
||||
def body
|
||||
RichText.new("markdown", self[:body])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<%= t ".comment_from_html", :user_link => link_to(comment.user.display_name, user_path(comment.user)),
|
||||
:comment_created_at => l(comment.created_at.to_datetime, :format => :friendly) %>
|
||||
</p>
|
||||
<p><%= comment.body %></p>
|
||||
<p><%= comment.body.to_html %></p>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
|
|
@ -6,4 +6,9 @@ class IssueCommentTest < ActiveSupport::TestCase
|
|||
assert_not comment.valid?
|
||||
assert_not_nil comment.errors[:body]
|
||||
end
|
||||
|
||||
test "body" do
|
||||
comment = create(:issue_comment)
|
||||
assert_instance_of(RichText::Markdown, comment.body)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue