Commit 1e5888d1 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'api-project-issues-404' into 'master'

Return 404 in project issues API endpoint when project cannot be found

Closes #29631

See merge request !10093
parents 46146e33 8ab347b3
---
title: Return 404 in project issues API endpoint when project cannot be found
merge_request: 10093
author:
...@@ -91,7 +91,7 @@ module API ...@@ -91,7 +91,7 @@ module API
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
project = find_project(params[:id]) project = find_project!(params[:id])
issues = find_issues(project_id: project.id) issues = find_issues(project_id: project.id)
......
...@@ -103,7 +103,7 @@ module API ...@@ -103,7 +103,7 @@ module API
use :issues_params use :issues_params
end end
get ":id/issues" do get ":id/issues" do
project = find_project(params[:id]) project = find_project!(params[:id])
issues = find_issues(project_id: project.id) issues = find_issues(project_id: project.id)
......
...@@ -534,6 +534,12 @@ describe API::Issues, api: true do ...@@ -534,6 +534,12 @@ describe API::Issues, api: true do
describe "GET /projects/:id/issues" do describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" } let(:base_url) { "/projects/#{project.id}" }
it 'returns 404 when project does not exist' do
get api('/projects/1000/issues', non_member)
expect(response).to have_http_status(404)
end
it "returns 404 on private projects for other users" do it "returns 404 on private projects for other users" do
private_project = create(:empty_project, :private) private_project = create(:empty_project, :private)
create(:issue, project: private_project) create(:issue, project: private_project)
......
...@@ -439,6 +439,12 @@ describe API::V3::Issues, api: true do ...@@ -439,6 +439,12 @@ describe API::V3::Issues, api: true do
describe "GET /projects/:id/issues" do describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" } let(:base_url) { "/projects/#{project.id}" }
it 'returns 404 when project does not exist' do
get v3_api('/projects/1000/issues', non_member)
expect(response).to have_http_status(404)
end
it "returns 404 on private projects for other users" do it "returns 404 on private projects for other users" do
private_project = create(:empty_project, :private) private_project = create(:empty_project, :private)
create(:issue, project: private_project) create(:issue, project: private_project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment