diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-07-08 18:06:05 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-07-08 18:06:05 +0300 |
commit | ec39a1d63d8a7952930442165f1ad828939749b2 (patch) | |
tree | 16ecb322b5842a3a1b33aa8c199b7e58805bad4c /spec/workers | |
parent | ededb334c66fa25cb8518258d85b1f7da1dd8f26 (diff) |
Schedule namespace aggregation in other contexts
Schedules a Namespace::AggregationSchedule worker if some of the project
statistics are refreshed.
The worker is only executed if the feature flag is enabled.
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/project_cache_worker_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index 51afb076da1..edc55920b8e 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -36,6 +36,11 @@ describe ProjectCacheWorker do end context 'with an existing project' do + before do + lease_key = "namespace:namespaces_root_statistics:#{project.namespace_id}" + stub_exclusive_lease_taken(lease_key, timeout: Namespace::AggregationSchedule::DEFAULT_LEASE_TIMEOUT) + end + it 'refreshes the method caches' do expect_any_instance_of(Repository).to receive(:refresh_method_caches) .with(%i(readme)) @@ -81,6 +86,10 @@ describe ProjectCacheWorker do expect(UpdateProjectStatisticsWorker).not_to receive(:perform_in) + expect(Namespaces::ScheduleAggregationWorker) + .not_to receive(:perform_async) + .with(project.namespace_id) + worker.update_statistics(project, statistics) end end @@ -98,6 +107,11 @@ describe ProjectCacheWorker do .with(lease_timeout, project.id, statistics) .and_call_original + expect(Namespaces::ScheduleAggregationWorker) + .to receive(:perform_async) + .with(project.namespace_id) + .twice + worker.update_statistics(project, statistics) end end |