summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-09-01 14:03:57 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-09-14 14:50:32 +0200
commit994e7d135947ca162c147c5e0992a0190de22808 (patch)
treecd9ea4d93269c8597541f8c59e89a83ca2b56d2b /spec/requests
parent2b82f907abf2074ac332531d6142893d081f44b9 (diff)
downloadgitlab-ce-994e7d135947ca162c147c5e0992a0190de22808.tar.gz
Create system notes for MR too, improve doc + clean up code
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/notes_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index f5882c0c74a..fb440fa551c 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -302,6 +302,40 @@ describe API::Notes do
expect(private_issue.notes.reload).to be_empty
end
end
+
+ context 'when the merge request discussion is locked' do
+ before do
+ merge_request.update_attribute(:discussion_locked, true)
+ end
+
+ context 'when a user is a team member' do
+ subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user), body: 'Hi!' }
+
+ it 'returns 200 status' do
+ subject
+
+ expect(response).to have_http_status(201)
+ end
+
+ it 'creates a new note' do
+ expect { subject }.to change { Note.count }.by(1)
+ end
+ end
+
+ context 'when a user is not a team member' do
+ subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", private_user), body: 'Hi!' }
+
+ it 'returns 403 status' do
+ subject
+
+ expect(response).to have_http_status(403)
+ end
+
+ it 'does not create a new note' do
+ expect { subject }.not_to change { Note.count }
+ end
+ end
+ end
end
describe "POST /projects/:id/noteable/:noteable_id/notes to test observer on create" do