diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-17 11:15:57 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-17 11:30:07 +0100 |
commit | 0de85b53194f582e8fc3267f14b7a5038440e401 (patch) | |
tree | 082124f1e8907ff0b9b3b26d2d4870d286e27599 | |
parent | db3289be55f5efe7523d2e8119f549b93c140b92 (diff) | |
download | gitlab-ce-0de85b53194f582e8fc3267f14b7a5038440e401.tar.gz |
Remove a wat in NamespacelessProjectDestroyWorker
-rw-r--r-- | app/models/project.rb | 3 | ||||
-rw-r--r-- | app/workers/namespaceless_project_destroy_worker.rb | 4 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 23 |
3 files changed, 26 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 22b347cc8f9..5416786b4aa 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1224,6 +1224,9 @@ class Project < ActiveRecord::Base # TODO: what to do here when not using Legacy Storage? Do we still need to rename and delay removal? def remove_pages + # Projects with a missing namespace cannot have their pages removed + return unless namespace + ::Projects::UpdatePagesConfigurationService.new(self).execute # 1. We rename pages to temporary directory diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb index bfae0c77700..a9073742ff7 100644 --- a/app/workers/namespaceless_project_destroy_worker.rb +++ b/app/workers/namespaceless_project_destroy_worker.rb @@ -24,10 +24,6 @@ class NamespacelessProjectDestroyWorker unlink_fork(project) if project.forked? - # Override Project#remove_pages for this instance so it doesn't do anything - def project.remove_pages - end - project.destroy! end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index eba71ba2f72..361a4c022ca 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2311,6 +2311,29 @@ describe Project do end end + describe '#remove_pages' do + let(:project) { create(:project) } + let(:pages_path) { project.pages_path } + + around do |example| + FileUtils.mkdir_p(pages_path) + begin + example.run + ensure + FileUtils.rm_rf(pages_path) + end + end + + it 'is a no-op when there is no namespace' do + project.update_column(:namespace_id, nil) + + expect_any_instance_of(Projects::UpdatePagesConfigurationService).not_to receive(:execute) + expect_any_instance_of(Gitlab::PagesTransfer).not_to receive(:rename_project) + + project.remove_pages + end + end + describe '#forks_count' do it 'returns the number of forks' do project = build(:project) |