diff options
Diffstat (limited to 'spec/workers/repository_import_worker_spec.rb')
-rw-r--r-- | spec/workers/repository_import_worker_spec.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 2b1a617ee62..f0884ad0aff 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -11,17 +11,22 @@ describe RepositoryImportWorker do let(:project) { create(:project, :import_scheduled) } context 'when worker was reset without cleanup' do - let(:jid) { '12345678' } - let(:started_project) { create(:project, :import_started, import_jid: jid) } - it 'imports the project successfully' do + jid = '12345678' + started_project = create(:project) + + create(:import_state, :started, project: started_project, jid: jid) + allow(subject).to receive(:jid).and_return(jid) expect_any_instance_of(Projects::ImportService).to receive(:execute) .and_return({ status: :ok }) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - expect_any_instance_of(Project).to receive(:import_finish) + # Works around https://github.com/rspec/rspec-mocks/issues/910 + expect(Project).to receive(:find).with(project.id).and_return(project) + expect(project.repository).to receive(:expire_emptiness_caches) + expect(project.wiki.repository).to receive(:expire_emptiness_caches) + expect(project).to receive(:import_finish) subject.perform(project.id) end @@ -32,9 +37,11 @@ describe RepositoryImportWorker do expect_any_instance_of(Projects::ImportService).to receive(:execute) .and_return({ status: :ok }) - expect_any_instance_of(Project).to receive(:after_import).and_call_original - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - expect_any_instance_of(Project).to receive(:import_finish) + # Works around https://github.com/rspec/rspec-mocks/issues/910 + expect(Project).to receive(:find).with(project.id).and_return(project) + expect(project.repository).to receive(:expire_emptiness_caches) + expect(project.wiki.repository).to receive(:expire_emptiness_caches) + expect(project).to receive(:import_finish) subject.perform(project.id) end |