Fix notes creation via API

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-06-18 09:26:04 +03:00
parent 73f91da8b1
commit 85333f093b
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
1 changed files with 8 additions and 5 deletions

View File

@ -50,12 +50,15 @@ module API
post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
required_attributes! [:body]
@noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"])
@note = @noteable.notes.new(note: params[:body])
@note.author = current_user
@note.project = user_project
opts = {
note: params[:body],
noteable_type: noteables_str.classify,
noteable_id: params[noteable_id_str]
}
if @note.save
@note = ::Notes::CreateService.new(user_project, current_user, opts).execute
if @note.valid?
present @note, with: Entities::Note
else
not_found!