Remove factories from projects cleanup spec

This commit is contained in:
Sean McGivern 2019-03-12 10:19:20 +00:00
parent 853054e090
commit b0668b3418

View file

@ -1,20 +1,17 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb')
describe CleanupNonexistingNamespacePendingDeleteProjects do
before do
# Stub after_save callbacks that will fail when Project has invalid namespace
allow_any_instance_of(Project).to receive(:ensure_storage_path_exist).and_return(nil)
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
end
describe CleanupNonexistingNamespacePendingDeleteProjects, :migration do
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
describe '#up' do
set(:some_project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let!(:some_project) { projects.create! }
let(:namespace) { namespaces.create!(name: 'test', path: 'test') }
it 'only cleans up when namespace does not exist' do
create(:project, pending_delete: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs
project = build(:project, pending_delete: true, namespace: nil, namespace_id: Namespace.maximum(:id).to_i.succ) # rubocop:disable RSpec/FactoriesInMigrationSpecs
project.save(validate: false)
projects.create!(pending_delete: true, namespace_id: namespace.id)
project = projects.create!(pending_delete: true, namespace_id: 0)
expect(NamespacelessProjectDestroyWorker).to receive(:bulk_perform_async).with([[project.id]])
@ -22,7 +19,7 @@ describe CleanupNonexistingNamespacePendingDeleteProjects do
end
it 'does nothing when no pending delete projects without namespace found' do
create(:project, pending_delete: true, namespace: create(:namespace)) # rubocop:disable RSpec/FactoriesInMigrationSpecs
projects.create!(pending_delete: true, namespace_id: namespace.id)
expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async)