require'spec_helper'requireRails.root.join('db','post_migrate','20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb')describeCleanupNonexistingNamespacePendingDeleteProjectsdobeforedo# Stub after_save callbacks that will fail when Project has invalid namespaceallow_any_instance_of(Project).toreceive(:ensure_storage_path_exist).and_return(nil)allow_any_instance_of(Project).toreceive(:update_project_statistics).and_return(nil)enddescribe'#up'doset(:some_project){create(:project)}it'only cleans up when namespace does not exist'docreate(:project,pending_delete: true)project=build(:project,pending_delete: true,namespace: nil,namespace_id: Namespace.maximum(:id).to_i.succ)project.save(validate: false)expect(NamespacelessProjectDestroyWorker).toreceive(:bulk_perform_async).with([[project.id]])described_class.new.upendit'does nothing when no pending delete projects without namespace found'docreate(:project,pending_delete: true,namespace: create(:namespace))expect(NamespacelessProjectDestroyWorker).not_toreceive(:bulk_perform_async)described_class.new.upendendend