Maintenance: Fixed cache test that is error prone to timezone DST changes.
This commit is contained in:
parent
eb9767278d
commit
a1bb61bf56
1 changed files with 17 additions and 8 deletions
|
@ -42,11 +42,19 @@ RSpec.describe Cache do
|
|||
.to change { Cache.get('123') }.to({ key: 'some valueöäüß' })
|
||||
end
|
||||
|
||||
context 'when expiring' do
|
||||
|
||||
# we need to travel to a fixed point in time
|
||||
# to prevent influences of timezone / DST
|
||||
before do
|
||||
travel_to '1995-12-21 13:37 +0100'
|
||||
end
|
||||
|
||||
it 'defaults to expires_in: 7.days' do
|
||||
Cache.write('123', 'some value')
|
||||
|
||||
expect { travel 7.days }.not_to change { Cache.get('123') }
|
||||
expect { travel 1.second }.to change { Cache.get('123') }.to(nil)
|
||||
expect { travel 7.days - 1.second }.not_to change { Cache.get('123') }
|
||||
expect { travel 2.seconds }.to change { Cache.get('123') }.to(nil)
|
||||
end
|
||||
|
||||
it 'accepts a custom :expires_in option' do
|
||||
|
@ -55,6 +63,7 @@ RSpec.describe Cache do
|
|||
expect { travel 4.seconds }.to change { Cache.get('123') }.to(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.delete' do
|
||||
it 'deletes stored values' do
|
||||
|
|
Loading…
Reference in a new issue