diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-05-14 17:12:18 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-05-14 17:12:18 +0300 |
commit | 2c29e80a93dffb1a854f4c63171b1a91eddea8d9 (patch) | |
tree | 7c40c2f31bd4282acc433602a5457224efe17feb /spec/models | |
parent | 13f68f55b31847fc8fab03ce3aadf92c930dd531 (diff) |
Check for exact time matches
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/redis_cacheable_spec.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb index bd5319a0c8c..2e496cfb439 100644 --- a/spec/models/concerns/redis_cacheable_spec.rb +++ b/spec/models/concerns/redis_cacheable_spec.rb @@ -79,6 +79,8 @@ describe RedisCacheable do describe '#cached_attr_time_reader', :clean_gitlab_redis_shared_state do subject { instance.time } + let(:other_time) { Time.zone.parse('May 14 2018') } + before do model.cached_attr_time_reader(:time) end @@ -88,7 +90,7 @@ describe RedisCacheable do expect(instance).to receive(:read_attribute).and_call_original expect(subject).to be_instance_of(ActiveSupport::TimeWithZone) - expect(subject).to be_within(1.minute).of(Time.zone.now) + expect(subject).to eq(payload[:time]) end end @@ -96,19 +98,19 @@ describe RedisCacheable do it 'reads the cached value' do expect(instance).not_to receive(:read_attribute) - instance.cache_attributes(time: Time.zone.now) + instance.cache_attributes(time: other_time) expect(subject).to be_instance_of(ActiveSupport::TimeWithZone) - expect(subject).to be_within(1.minute).of(Time.zone.now) + expect(subject).to eq(other_time) end end it 'always returns the latest values' do - expect(instance.time).to be_within(1.minute).of(Time.zone.now) + expect(instance.time).to eq(payload[:time]) - instance.cache_attributes(time: 1.hour.ago) + instance.cache_attributes(time: other_time) - expect(instance.time).to be_within(1.minute).of(1.hour.ago) + expect(instance.time).to eq(other_time) end end end |