diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-05 18:37:44 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-06 17:02:30 +0100 |
commit | f978a71f41d5546be2c0c6b33052979c06912bd1 (patch) | |
tree | 9dc44e2dd44b1d27629a3a158eee6056fb551c13 | |
parent | 3f4e215c804f13def585dea995efa29b2af266ec (diff) | |
download | gitlab-ce-f978a71f41d5546be2c0c6b33052979c06912bd1.tar.gz |
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.
-rw-r--r-- | lib/api/merge_requests.rb | 3 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index ec63b352474..a0ca3026acb 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -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 diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index bf87ecbdc6f..531b56b8e53 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -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 |