Commit b0668b34 authored by Sean McGivern's avatar Sean McGivern

Remove factories from projects cleanup spec

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