Fix notes creation via API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
		
							parent
							
								
									73f91da8b1
								
							
						
					
					
						commit
						85333f093b
					
				| 
						 | 
					@ -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]
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if @note.save
 | 
					          @note = ::Notes::CreateService.new(user_project, current_user, opts).execute
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if @note.valid?
 | 
				
			||||||
            present @note, with: Entities::Note
 | 
					            present @note, with: Entities::Note
 | 
				
			||||||
          else
 | 
					          else
 | 
				
			||||||
            not_found!
 | 
					            not_found!
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue