summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-08-08 17:40:22 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-08-11 11:45:09 +0100
commit21066e827ab6b957b0948b025745b563f01a00d5 (patch)
tree088a6b6427fc2455a40c0db881046cc4645cc61f
parent86f5a4aaf19935b4d23a81426c1576bc16024696 (diff)
downloadgitlab-ce-21066e827ab6b957b0948b025745b563f01a00d5.tar.gz
Pending delete projects no longer return 500 error in Admins projects view35435-pending-delete-project-error-in-admin-interface-fix
-rw-r--r--app/finders/admin/projects_finder.rb2
-rw-r--r--changelogs/unreleased/35435-pending-delete-project-error-in-admin-interface-fix.yml4
-rw-r--r--spec/controllers/admin/projects_controller_spec.rb12
-rw-r--r--spec/finders/admin/projects_finder_spec.rb6
4 files changed, 23 insertions, 1 deletions
diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb
index a5ba791a513..7176bfe22d6 100644
--- a/app/finders/admin/projects_finder.rb
+++ b/app/finders/admin/projects_finder.rb
@@ -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?
diff --git a/changelogs/unreleased/35435-pending-delete-project-error-in-admin-interface-fix.yml b/changelogs/unreleased/35435-pending-delete-project-error-in-admin-interface-fix.yml
new file mode 100644
index 00000000000..8539615faac
--- /dev/null
+++ b/changelogs/unreleased/35435-pending-delete-project-error-in-admin-interface-fix.yml
@@ -0,0 +1,4 @@
+---
+title: Project pending delete no longer return 500 error in admins projects view
+merge_request: 13389
+author:
diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb
index 65587064eb1..373260b3978 100644
--- a/spec/controllers/admin/projects_controller_spec.rb
+++ b/spec/controllers/admin/projects_controller_spec.rb
@@ -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
diff --git a/spec/finders/admin/projects_finder_spec.rb b/spec/finders/admin/projects_finder_spec.rb
index 4e367d39cf3..28e36330029 100644
--- a/spec/finders/admin/projects_finder_spec.rb
+++ b/spec/finders/admin/projects_finder_spec.rb
@@ -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) }