diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-10 18:56:35 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-10 18:56:35 +0400 |
commit | f8ea52c3a0fe29daf76fbd7a0e65399c09c95f5a (patch) | |
tree | 6f1df03a8ca996cce004a28c57f6e1e88ed72f7b /lib | |
parent | a7be3dfa30a452b307d1fdc0b4157ecbe908da8d (diff) |
Remove thread vars usage from API notes and mr's
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 19 | ||||
-rw-r--r-- | lib/api/notes.rb | 40 |
2 files changed, 26 insertions, 33 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 017cb1f562e..fc1f1254a9e 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -184,21 +184,18 @@ module API # POST /projects/:id/merge_request/:merge_request_id/comments # post ":id/merge_request/:merge_request_id/comments" do - set_current_user_for_thread do - required_attributes! [:note] + required_attributes! [:note] - merge_request = user_project.merge_requests.find(params[:merge_request_id]) - note = merge_request.notes.new(note: params[:note], project_id: user_project.id) - note.author = current_user + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + note = merge_request.notes.new(note: params[:note], project_id: user_project.id) + note.author = current_user - if note.save - present note, with: Entities::MRNote - else - not_found! - end + if note.save + present note, with: Entities::MRNote + else + not_found! end end - end end end diff --git a/lib/api/notes.rb b/lib/api/notes.rb index f21907b1ffc..cb2bc764476 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -41,19 +41,17 @@ module API # Example Request: # POST /projects/:id/notes post ":id/notes" do - set_current_user_for_thread do - required_attributes! [:body] + required_attributes! [:body] - @note = user_project.notes.new(note: params[:body]) - @note.author = current_user + @note = user_project.notes.new(note: params[:body]) + @note.author = current_user - if @note.save - present @note, with: Entities::Note - else - # :note is exposed as :body, but :note is set on error - bad_request!(:note) if @note.errors[:note].any? - not_found! - end + if @note.save + present @note, with: Entities::Note + else + # :note is exposed as :body, but :note is set on error + bad_request!(:note) if @note.errors[:note].any? + not_found! end end @@ -99,19 +97,17 @@ module API # POST /projects/:id/issues/:noteable_id/notes # POST /projects/:id/snippets/:noteable_id/notes post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do - set_current_user_for_thread do - required_attributes! [:body] + 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 + @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 - if @note.save - present @note, with: Entities::Note - else - not_found! - end + if @note.save + present @note, with: Entities::Note + else + not_found! end end end |