Pending delete projects no longer return 500 error in Admins projects view

This commit is contained in:
Tiago Botelho 2017-08-08 17:40:22 +01:00
parent 86f5a4aaf1
commit 21066e827a
4 changed files with 23 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class Admin::ProjectsFinder
end
def execute
items = Project.with_statistics
items = Project.without_deleted.with_statistics
items = items.in_namespace(namespace_id) if namespace_id.present?
items = items.where(visibility_level: visibility_level) if visibility_level.present?
items = items.with_push if with_push.present?

View File

@ -0,0 +1,4 @@
---
title: Project pending delete no longer return 500 error in admins projects view
merge_request: 13389
author:

View File

@ -12,12 +12,24 @@ describe Admin::ProjectsController do
it 'retrieves the project for the given visibility level' do
get :index, visibility_level: [Gitlab::VisibilityLevel::PUBLIC]
expect(response.body).to match(project.name)
end
it 'does not retrieve the project' do
get :index, visibility_level: [Gitlab::VisibilityLevel::INTERNAL]
expect(response.body).not_to match(project.name)
end
it 'does not respond with projects pending deletion' do
pending_delete_project = create(:project, pending_delete: true)
get :index
expect(response).to have_http_status(200)
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
end
end

View File

@ -38,6 +38,12 @@ describe Admin::ProjectsFinder do
it { is_expected.to match_array([shared_project, public_project, internal_project, private_project]) }
end
context 'with pending delete project' do
let!(:pending_delete_project) { create(:project, pending_delete: true) }
it { is_expected.not_to include(pending_delete_project) }
end
context 'filter by namespace_id' do
let(:namespace) { create(:namespace) }
let!(:project_in_namespace) { create(:project, namespace: namespace) }