Commit 85333f09 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix notes creation via API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 73f91da8
...@@ -50,12 +50,15 @@ module API ...@@ -50,12 +50,15 @@ module API
post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
required_attributes! [:body] required_attributes! [:body]
@noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) opts = {
@note = @noteable.notes.new(note: params[:body]) note: params[:body],
@note.author = current_user noteable_type: noteables_str.classify,
@note.project = user_project noteable_id: params[noteable_id_str]
}
@note = ::Notes::CreateService.new(user_project, current_user, opts).execute
if @note.save if @note.valid?
present @note, with: Entities::Note present @note, with: Entities::Note
else else
not_found! not_found!
......
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