2017-05-08 11:13:02 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'post_migrate', '20170502101023_cleanup_namespaceless_pending_delete_projects.rb')
|
|
|
|
|
2018-03-01 09:09:09 -05:00
|
|
|
describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222043024 do
|
2017-05-08 11:13:02 -04:00
|
|
|
before do
|
|
|
|
# Stub after_save callbacks that will fail when Project has no namespace
|
2017-08-15 22:49:54 -04:00
|
|
|
allow_any_instance_of(Project).to receive(:ensure_storage_path_exists).and_return(nil)
|
2017-05-08 11:13:02 -04:00
|
|
|
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#up' do
|
|
|
|
it 'only cleans up pending delete projects' do
|
2017-08-02 15:55:11 -04:00
|
|
|
create(:project)
|
|
|
|
create(:project, pending_delete: true)
|
|
|
|
project = build(:project, pending_delete: true, namespace_id: nil)
|
2017-05-08 11:13:02 -04:00
|
|
|
project.save(validate: false)
|
|
|
|
|
2017-05-10 21:33:51 -04:00
|
|
|
expect(NamespacelessProjectDestroyWorker).to receive(:bulk_perform_async).with([[project.id]])
|
2017-05-09 16:16:52 -04:00
|
|
|
|
|
|
|
described_class.new.up
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does nothing when no pending delete projects without namespace found' do
|
2017-08-02 15:55:11 -04:00
|
|
|
create(:project)
|
|
|
|
create(:project, pending_delete: true)
|
2017-05-09 16:16:52 -04:00
|
|
|
|
|
|
|
expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async)
|
2017-05-08 11:13:02 -04:00
|
|
|
|
|
|
|
described_class.new.up
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|