diff options
author | Sean McGivern <sean@gitlab.com> | 2019-03-12 10:19:20 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-12 14:09:30 +0000 |
commit | b0668b3418bab7d280f0467f26a0fe6a441b3da5 (patch) | |
tree | 9ca5a53da8d3a34f022cc441bb7edb114f2ff9ca /spec/migrations | |
parent | 853054e090031f070d18ea0819bef514c5dedad5 (diff) | |
download | gitlab-ce-b0668b3418bab7d280f0467f26a0fe6a441b3da5.tar.gz |
Remove factories from projects cleanup spec
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb index 8f40ac3e38b..0e6bded29b4 100644 --- a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb +++ b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb @@ -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) |