Commit bfce5d71 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Render json message with errors if note didn't pass validation

parent c92b6e66
...@@ -131,16 +131,20 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -131,16 +131,20 @@ class Projects::NotesController < Projects::ApplicationController
end end
def render_note_json(note) def render_note_json(note)
render json: { if note.valid?
id: note.id, render json: {
discussion_id: note.discussion_id, id: note.id,
html: note_to_html(note), discussion_id: note.discussion_id,
award: note.is_award, html: note_to_html(note),
emoji_path: note.is_award ? view_context.image_url(::AwardEmoji.path_to_emoji_image(note.note)) : "", award: note.is_award,
note: note.note, emoji_path: note.is_award ? view_context.image_url(::AwardEmoji.path_to_emoji_image(note.note)) : "",
discussion_html: note_to_discussion_html(note), note: note.note,
discussion_with_diff_html: note_to_discussion_with_diff_html(note) discussion_html: note_to_discussion_html(note),
} discussion_with_diff_html: note_to_discussion_with_diff_html(note)
}
else
render json: { invalid: true, errors: note.errors }
end
end end
def authorize_admin_note! def authorize_admin_note!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment