diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-21 14:57:38 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-03-21 14:57:38 +0300 |
commit | 1e5888d115df1973cd5af0aa95013dbbf29ddefd (patch) | |
tree | 77f1c1b30d10b5738e0554d3cfc0b36fcb5bf309 | |
parent | 46146e33f2f8dcbd52ee50eb9142887344b8c367 (diff) | |
parent | 8ab347b392bc635ebfb0eb1663bff7d0048fc5c9 (diff) |
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
-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) |