summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-12-29 21:06:49 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-12-29 21:06:49 +0200
commita9cf84e5acf1385391279eaa49e9b0d34c3050b9 (patch)
treea28b2e4a1655590bf558ff0dfae306ef3b7ecc73 /spec/requests
parent159ba9b9585d6795a45d7c986eabbf54e74b3bec (diff)
parent1fbc01024123c44740e1c94cab5a74faf2856a21 (diff)
downloadgitlab-ce-a9cf84e5acf1385391279eaa49e9b0d34c3050b9.tar.gz
Merge pull request #7675 from yglukhov/patch_notes_api
Implemented notes (body) patching in API.
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/notes_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 7aa53787aed..429824e829a 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -131,4 +131,58 @@ describe API::API, api: true do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
end
end
+
+ describe 'PUT /projects/:id/noteable/:noteable_id/notes/:note_id' do
+ context 'when noteable is an Issue' do
+ it 'should return modified note' do
+ put api("/projects/#{project.id}/issues/#{issue.id}/"\
+ "notes/#{issue_note.id}", user), body: 'Hello!'
+ response.status.should == 200
+ json_response['body'].should == 'Hello!'
+ end
+
+ it 'should return a 404 error when note id not found' do
+ put api("/projects/#{project.id}/issues/#{issue.id}/notes/123", user),
+ body: 'Hello!'
+ response.status.should == 404
+ end
+
+ it 'should return a 400 bad request error if body not given' do
+ put api("/projects/#{project.id}/issues/#{issue.id}/"\
+ "notes/#{issue_note.id}", user)
+ response.status.should == 400
+ end
+ end
+
+ context 'when noteable is a Snippet' do
+ it 'should return modified note' do
+ put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
+ "notes/#{snippet_note.id}", user), body: 'Hello!'
+ response.status.should == 200
+ json_response['body'].should == 'Hello!'
+ end
+
+ it 'should return a 404 error when note id not found' do
+ put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
+ "notes/123", user), body: "Hello!"
+ response.status.should == 404
+ end
+ end
+
+ context 'when noteable is a Merge Request' do
+ it 'should return modified note' do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
+ "notes/#{merge_request_note.id}", user), body: 'Hello!'
+ response.status.should == 200
+ json_response['body'].should == 'Hello!'
+ end
+
+ it 'should return a 404 error when note id not found' do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
+ "notes/123", user), body: "Hello!"
+ response.status.should == 404
+ end
+ end
+ end
+
end