diff options
Diffstat (limited to 'spec/workers/project_cache_worker_spec.rb')
-rw-r--r-- | spec/workers/project_cache_worker_spec.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index 0f91f7af255..7f42c700ce4 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -5,8 +5,9 @@ require 'spec_helper' RSpec.describe ProjectCacheWorker do include ExclusiveLeaseHelpers + let_it_be(:project) { create(:project, :repository) } + let(:worker) { described_class.new } - let(:project) { create(:project, :repository) } let(:lease_key) { ["project_cache_worker", project.id, *statistics.sort].join(":") } let(:lease_timeout) { ProjectCacheWorker::LEASE_TIMEOUT } let(:statistics) { [] } @@ -126,4 +127,15 @@ RSpec.describe ProjectCacheWorker do end end end + + it_behaves_like 'an idempotent worker' do + let(:job_args) { [project.id, %w(readme), %w(repository_size)] } + + it 'calls Projects::UpdateStatisticsService service twice', :clean_gitlab_redis_shared_state do + expect(Projects::UpdateStatisticsService).to receive(:new).once.and_return(double(execute: true)) + expect(UpdateProjectStatisticsWorker).to receive(:perform_in).once + + subject + end + end end |