summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/requests/api/diff_discussions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/requests/api/diff_discussions.rb')
-rw-r--r--spec/support/shared_examples/requests/api/diff_discussions.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/support/shared_examples/requests/api/diff_discussions.rb b/spec/support/shared_examples/requests/api/diff_discussions.rb
index 76c6c93964a..a7774d17d3c 100644
--- a/spec/support/shared_examples/requests/api/diff_discussions.rb
+++ b/spec/support/shared_examples/requests/api/diff_discussions.rb
@@ -38,13 +38,24 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
expect(json_response['notes'].first['position']).to eq(position.stringify_keys)
end
- it "returns a 400 bad request error when position is invalid" do
- position = diff_note.position.to_h.merge(new_line: '100000')
+ context "when position is invalid" do
+ it "returns a 400 bad request error when position is not plausible" do
+ position = diff_note.position.to_h.merge(new_line: '100000')
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
- params: { body: 'hi!', position: position }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
+ params: { body: 'hi!', position: position }
+
+ expect(response).to have_gitlab_http_status(400)
+ end
+
+ it "returns a 400 bad request error when the position is not valid for this discussion" do
+ position = diff_note.position.to_h.merge(new_line: '588440f66559714280628a4f9799f0c4eb880a4a')
+
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
+ params: { body: 'hi!', position: position }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(400)
+ end
end
end