summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-08-17 11:36:58 +0100
committerNick Thomas <nick@gitlab.com>2017-08-17 11:44:09 +0100
commitc9856e53ea05374dcab0a591bd0352d321120b68 (patch)
tree952573906ee0e2b326adaa9e38a7daa9aed163ea
parent0de85b53194f582e8fc3267f14b7a5038440e401 (diff)
downloadgitlab-ce-c9856e53ea05374dcab0a591bd0352d321120b68.tar.gz
Run remove_pages in a run_after_commit block
-rw-r--r--app/models/project.rb2
-rw-r--r--changelogs/unreleased/35072-fix-pages-delete.yml5
-rw-r--r--spec/models/project_spec.rb15
3 files changed, 21 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 5416786b4aa..89b4debcd42 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -60,7 +60,7 @@ class Project < ActiveRecord::Base
end
before_destroy :remove_private_deploy_keys
- after_destroy :remove_pages
+ after_destroy -> { run_after_commit { remove_pages } }
# update visibility_level of forks
after_update :update_forks_visibility_level
diff --git a/changelogs/unreleased/35072-fix-pages-delete.yml b/changelogs/unreleased/35072-fix-pages-delete.yml
new file mode 100644
index 00000000000..21af2bde201
--- /dev/null
+++ b/changelogs/unreleased/35072-fix-pages-delete.yml
@@ -0,0 +1,5 @@
+---
+title: Fix deleting GitLab Pages files when a project is removed
+merge_request: 13631
+author:
+type: fixed
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 361a4c022ca..e1d64986a76 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2313,6 +2313,7 @@ describe Project do
describe '#remove_pages' do
let(:project) { create(:project) }
+ let(:namespace) { project.namespace }
let(:pages_path) { project.pages_path }
around do |example|
@@ -2324,6 +2325,14 @@ describe Project do
end
end
+ it 'removes the pages directory' do
+ expect_any_instance_of(Projects::UpdatePagesConfigurationService).to receive(:execute)
+ expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return(true)
+ expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, namespace.full_path, anything)
+
+ project.remove_pages
+ end
+
it 'is a no-op when there is no namespace' do
project.update_column(:namespace_id, nil)
@@ -2332,6 +2341,12 @@ describe Project do
project.remove_pages
end
+
+ it 'is run when the project is destroyed' do
+ expect(project).to receive(:remove_pages).and_call_original
+
+ project.destroy
+ end
end
describe '#forks_count' do