summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-18 09:26:04 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-18 09:26:04 +0300
commit85333f093b5f56a06a86a0a9bacfc501622b4917 (patch)
tree142e37f7df92650a9f53b271bd33161ba9b3450d /lib
parent73f91da8b19be5b98b5c4e11cf27ceb50eb6c20b (diff)
downloadgitlab-ce-85333f093b5f56a06a86a0a9bacfc501622b4917.tar.gz
Fix notes creation via API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/api/notes.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index 413faf0cf2d..0ef9a3c4beb 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -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]
+ }
+
+ @note = ::Notes::CreateService.new(user_project, current_user, opts).execute
- if @note.save
+ if @note.valid?
present @note, with: Entities::Note
else
not_found!