summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-06-19 18:24:14 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-06-28 17:51:05 +0100
commit1fbb7f977777de7c8808429693359c7a98ffdfcc (patch)
treebb872e346a9fb3b6c6d9001196ee931dba632387
parent34f57b462bc14ad194cf890a4585d403bdbde55c (diff)
downloadgitlab-ce-30708-stop-using-deleted-at-to-filter-namespaces.tar.gz
Removes redundant pending delete checks30708-stop-using-deleted-at-to-filter-namespaces
-rw-r--r--app/finders/todos_finder.rb3
-rw-r--r--app/helpers/search_helper.rb4
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/project.rb5
-rw-r--r--app/services/ci/register_job_service.rb6
-rw-r--r--spec/features/dashboard/todos/todos_spec.rb17
6 files changed, 10 insertions, 27 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 5a4c5767be5..3fe37c75381 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -78,7 +78,6 @@ class TodosFinder
end
def project
- return nil if @project&.pending_delete?
return @project if defined?(@project)
if project?
@@ -98,7 +97,7 @@ class TodosFinder
def projects(items)
item_project_ids = items.reorder(nil).select(:project_id)
- ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids).execute.without_deleted
+ ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids).execute
end
def type?
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 9c46035057f..8f15904f068 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -97,8 +97,8 @@ module SearchHelper
# Autocomplete results for the current user's projects
def projects_autocomplete(term, limit = 5)
- current_user.authorized_projects.search_by_title(term).
- sorted_by_stars.non_archived.limit(limit).map do |p|
+ current_user.authorized_projects.search_by_title(term)
+ .sorted_by_stars.non_archived.limit(limit).map do |p|
{
category: "Projects",
id: p.id,
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 583d4fb5244..efbed5a2ef5 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -47,6 +47,8 @@ class Namespace < ActiveRecord::Base
before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir
+ default_scope { with_deleted }
+
scope :for_user, -> { where('type IS NULL') }
scope :with_statistics, -> do
diff --git a/app/models/project.rb b/app/models/project.rb
index 40a8e7f07c6..65f81727071 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -222,7 +222,7 @@ class Project < ActiveRecord::Base
has_many :uploads, as: :model, dependent: :destroy
# Scopes
- scope :with_deleted, -> { where(pending_delete: true) }
+ scope :pending_delete, -> { where(pending_delete: true) }
scope :without_deleted, -> { where(pending_delete: false) }
scope :sorted_by_activity, -> { reorder(last_activity_at: :desc) }
@@ -376,7 +376,6 @@ class Project < ActiveRecord::Base
.or(ptable[:description].matches(pattern))
)
-
namespaces = unscoped.select(:id)
.joins(:namespace)
.where(ntable[:name].matches(pattern))
@@ -1456,7 +1455,7 @@ class Project < ActiveRecord::Base
def pending_delete_twin
return false unless path
- Project.with_deleted.find_by_full_path(path_with_namespace)
+ Project.pending_delete.find_by_full_path(path_with_namespace)
end
##
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 27bdb6b9a2f..b951e8d0c9f 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -54,9 +54,9 @@ module Ci
def builds_for_shared_runner
new_builds.
# don't run projects which have not enabled shared runners and builds
- joins(:project).where(projects: { shared_runners_enabled: true, pending_delete: false }).
- joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id').
- where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
+ joins(:project).where(projects: { shared_runners_enabled: true, pending_delete: false })
+ .joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id')
+ .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb
index 24da5db305f..7fa4d198e00 100644
--- a/spec/features/dashboard/todos/todos_spec.rb
+++ b/spec/features/dashboard/todos/todos_spec.rb
@@ -317,23 +317,6 @@ feature 'Dashboard Todos' do
end
end
- context 'User has a Todo in a project pending deletion' do
- before do
- deleted_project = create(:project, :public, pending_delete: true)
- create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author)
- create(:todo, :mentioned, user: user, project: deleted_project, target: issue, author: author, state: :done)
- sign_in(user)
- visit dashboard_todos_path
- end
-
- it 'shows "All done" message' do
- within('.todos-count') { expect(page).to have_content '0' }
- expect(page).to have_content 'To do 0'
- expect(page).to have_content 'Done 0'
- expect(page).to have_selector('.todos-all-done', count: 1)
- end
- end
-
context 'User has a Build Failed todo' do
let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) }