Creating MR comment without a note returns status code 400 (Bad request)

Creating a comment to an existing merge request via API without providing a note
returns a status code 400 now, suggesting a bad request. The reason for this
is the resource itself (MR) exists but the required property is not set.
This commit is contained in:
Sebastian Ziebell 2013-02-05 18:37:44 +01:00
parent 3f4e215c80
commit f978a71f41
2 changed files with 8 additions and 0 deletions

View file

@ -128,6 +128,9 @@ module Gitlab
if note.save
present note, with: Entities::MRNote
else
if note.errors[:note].any?
error!(note.errors[:note], 400)
end
not_found!
end
end

View file

@ -87,6 +87,11 @@ describe Gitlab::API do
response.status.should == 201
json_response['note'].should == 'My comment'
end
it "should return 400 if note is missing" do
post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user)
response.status.should == 400
end
end
end