diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-11 19:47:51 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-11 19:47:51 +0300 |
commit | 96ce4ed25c7633330f82439f1f9347f6eef8568a (patch) | |
tree | 39544ac46f9172132091fc25d867b94725df2011 /spec/workers/repository_import_worker_spec.rb | |
parent | 6defeb0a7d6928ad32d4d7a2fa35d0d71dbb9dea (diff) |
Work around limitations of expect_any_instance_of by stubbing Project.find
Diffstat (limited to 'spec/workers/repository_import_worker_spec.rb')
-rw-r--r-- | spec/workers/repository_import_worker_spec.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 84d1b38ef19..f0884ad0aff 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -22,8 +22,11 @@ describe RepositoryImportWorker do 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 @@ -34,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 |