Commit c9856e53 authored by Nick Thomas's avatar Nick Thomas

Run remove_pages in a run_after_commit block

parent 0de85b53
......@@ -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
......
---
title: Fix deleting GitLab Pages files when a project is removed
merge_request: 13631
author:
type: fixed
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment