diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/workers/concerns/reenqueuer_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/workers/concerns/reenqueuer_spec.rb')
-rw-r--r-- | spec/workers/concerns/reenqueuer_spec.rb | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/spec/workers/concerns/reenqueuer_spec.rb b/spec/workers/concerns/reenqueuer_spec.rb index 56db2239bb1..e7287b55af2 100644 --- a/spec/workers/concerns/reenqueuer_spec.rb +++ b/spec/workers/concerns/reenqueuer_spec.rb @@ -121,14 +121,7 @@ RSpec.describe Reenqueuer::ReenqueuerSleeper do # Unit test ensure_minimum_duration describe '#ensure_minimum_duration' do around do |example| - # Allow Timecop.travel without the block form - Timecop.safe_mode = false - - Timecop.freeze do - example.run - end - - Timecop.safe_mode = true + freeze_time { example.run } end let(:minimum_duration) { 4.seconds } @@ -140,31 +133,31 @@ RSpec.describe Reenqueuer::ReenqueuerSleeper do expect(dummy).to receive(:sleep).with(a_value_within(0.01).of(time_left)) dummy.ensure_minimum_duration(minimum_duration) do - Timecop.travel(minimum_duration - time_left) + travel(minimum_duration - time_left) end end end context 'when the block completes just before the minimum duration' do - let(:time_left) { 0.1.seconds } + let(:time_left) { 1.second } it 'sleeps until the minimum duration' do expect(dummy).to receive(:sleep).with(a_value_within(0.01).of(time_left)) dummy.ensure_minimum_duration(minimum_duration) do - Timecop.travel(minimum_duration - time_left) + travel(minimum_duration - time_left) end end end context 'when the block completes just after the minimum duration' do - let(:time_over) { 0.1.seconds } + let(:time_over) { 1.second } it 'does not sleep' do expect(dummy).not_to receive(:sleep) dummy.ensure_minimum_duration(minimum_duration) do - Timecop.travel(minimum_duration + time_over) + travel(minimum_duration + time_over) end end end @@ -176,7 +169,7 @@ RSpec.describe Reenqueuer::ReenqueuerSleeper do expect(dummy).not_to receive(:sleep) dummy.ensure_minimum_duration(minimum_duration) do - Timecop.travel(minimum_duration + time_over) + travel(minimum_duration + time_over) end end end |