Commit 75cfe861 authored by Sean McGivern's avatar Sean McGivern

Only schedule PagesTransferWorker when project has pages

If a project has no pages deployed, we don't need to schedule this
worker at all.
parent 0cfccf25
......@@ -97,6 +97,7 @@ module Projects
end
if ::Feature.enabled?(:async_pages_move_project_rename, project)
if project.pages_deployed?
# Block will be evaluated in the context of project so we need
# to bind to a local variable to capture it, as the instance
# variable and method aren't available on Project
......@@ -108,6 +109,7 @@ module Projects
.async
.rename_project(path_before_local, path, namespace.full_path)
end
end
else
Gitlab::PagesTransfer
.new
......
......@@ -75,13 +75,28 @@ RSpec.describe Projects::AfterRenameService do
end
end
context 'when the project has pages deployed' do
it 'schedules a move of the pages directory' do
allow(project).to receive(:pages_deployed?).and_return(true)
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
end
end
context 'when the project does not have pages deployed' do
it 'does nothing with the pages directory' do
allow(project).to receive(:pages_deployed?).and_return(false)
expect(PagesTransferWorker).not_to receive(:perform_async)
expect(Gitlab::PagesTransfer).not_to receive(:new)
service_execute
end
end
end
context 'attachments' do
before do
expect(project_storage).to receive(:rename_repo) { true }
......@@ -180,13 +195,28 @@ RSpec.describe Projects::AfterRenameService do
end
end
context 'when the project has pages deployed' do
it 'schedules a move of the pages directory' do
allow(project).to receive(:pages_deployed?).and_return(true)
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
end
end
context 'when the project does not have pages deployed' do
it 'does nothing with the pages directory' do
allow(project).to receive(:pages_deployed?).and_return(false)
expect(PagesTransferWorker).not_to receive(:perform_async)
expect(Gitlab::PagesTransfer).not_to receive(:new)
service_execute
end
end
end
context 'attachments' do
let(:uploader) { create(:upload, :issuable_upload, :with_file, model: project) }
let(:file_uploader) { build(:file_uploader, project: project) }
......
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