diff options
Diffstat (limited to 'spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb')
-rw-r--r-- | spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb index 11343f69d6f..491ea64cff1 100644 --- a/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb +++ b/spec/workers/metrics/dashboard/prune_old_annotations_worker_spec.rb @@ -10,23 +10,24 @@ RSpec.describe Metrics::Dashboard::PruneOldAnnotationsWorker do describe '#perform' do it 'removes all annotations older than cut off', :aggregate_failures do - Timecop.freeze(now) do + travel_to(now) do described_class.new.perform expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation, two_weeks_old_annotation]) # is idempotent in the scope of 24h expect { described_class.new.perform }.not_to change { Metrics::Dashboard::Annotation.all.to_a } - travel_to(24.hours.from_now) do - described_class.new.perform - expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation]) - end + end + + travel_to(now + 24.hours) do + described_class.new.perform + expect(Metrics::Dashboard::Annotation.all).to match_array([one_day_old_annotation]) end end context 'batch to be deleted is bigger than upper limit' do it 'schedules second job to clear remaining records' do - Timecop.freeze(now) do + travel_to(now) do create(:metrics_dashboard_annotation, starting_at: 1.month.ago) stub_const("#{described_class}::DELETE_LIMIT", 1) |