summaryrefslogtreecommitdiff
path: root/spec/requests/api/issue_links_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/issue_links_spec.rb')
-rw-r--r--spec/requests/api/issue_links_spec.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/requests/api/issue_links_spec.rb b/spec/requests/api/issue_links_spec.rb
index 45583f5c7dc..81dd4c3dfa0 100644
--- a/spec/requests/api/issue_links_spec.rb
+++ b/spec/requests/api/issue_links_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe API::IssueLinks do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- expect(response).to match_response_schema('public_api/v4/issue_links')
+ expect(response).to match_response_schema('public_api/v4/related_issues')
end
it 'returns multiple links without N + 1' do
@@ -205,16 +205,30 @@ RSpec.describe API::IssueLinks do
end
context 'when user has ability to delete the issue link' do
+ let_it_be(:target_issue) { create(:issue, project: project) }
+
+ before do
+ project.add_reporter(user)
+ end
+
it 'returns 200' do
- target_issue = create(:issue, project: project)
issue_link = create(:issue_link, source: issue, target: target_issue)
- project.add_reporter(user)
delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/issue_link')
end
+
+ it 'returns 404 when the issue link does not belong to the specified issue' do
+ other_issue = create(:issue, project: project)
+ issue_link = create(:issue_link, source: other_issue, target: target_issue)
+
+ delete api("/projects/#{project.id}/issues/#{issue.iid}/links/#{issue_link.id}", user)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ expect(json_response['message']).to eq('404 Not found')
+ end
end
end
end