diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2017-03-20 18:03:29 +0100 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2017-03-20 18:03:29 +0100 |
commit | 8ab347b392bc635ebfb0eb1663bff7d0048fc5c9 (patch) | |
tree | 46e2d8e6436db9e81fdb7a92bc9b5488806cc611 | |
parent | a1a04828e36f71e27b0a9958efd912989f826a9d (diff) | |
download | gitlab-ce-8ab347b392bc635ebfb0eb1663bff7d0048fc5c9.tar.gz |
Return 404 in project issues API endpoint when project cannot be found
Closes #29631
-rw-r--r-- | changelogs/unreleased/api-project-issues-404.yml | 4 | ||||
-rw-r--r-- | lib/api/issues.rb | 2 | ||||
-rw-r--r-- | lib/api/v3/issues.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/issues_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/v3/issues_spec.rb | 6 |
5 files changed, 18 insertions, 2 deletions
diff --git a/changelogs/unreleased/api-project-issues-404.yml b/changelogs/unreleased/api-project-issues-404.yml new file mode 100644 index 00000000000..ce40395c99e --- /dev/null +++ b/changelogs/unreleased/api-project-issues-404.yml @@ -0,0 +1,4 @@ +--- +title: Return 404 in project issues API endpoint when project cannot be found +merge_request: 10093 +author: diff --git a/lib/api/issues.rb b/lib/api/issues.rb index b3183357625..fd2674910d2 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -91,7 +91,7 @@ module API use :issues_params end get ":id/issues" do - project = find_project(params[:id]) + project = find_project!(params[:id]) issues = find_issues(project_id: project.id) diff --git a/lib/api/v3/issues.rb b/lib/api/v3/issues.rb index cead03b1e6b..54c6a8060b8 100644 --- a/lib/api/v3/issues.rb +++ b/lib/api/v3/issues.rb @@ -103,7 +103,7 @@ module API use :issues_params end get ":id/issues" do - project = find_project(params[:id]) + project = find_project!(params[:id]) issues = find_issues(project_id: project.id) diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index e7738ca3034..52f68fed2cc 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -534,6 +534,12 @@ describe API::Issues, api: true do describe "GET /projects/:id/issues" do 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 private_project = create(:empty_project, :private) create(:issue, project: private_project) diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 1941ca0d7d8..51021eec63c 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -439,6 +439,12 @@ describe API::V3::Issues, api: true do describe "GET /projects/:id/issues" do 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 private_project = create(:empty_project, :private) create(:issue, project: private_project) |