Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-14 16:54:23 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-05-14 16:54:23 +0300
commit13f68f55b31847fc8fab03ce3aadf92c930dd531 (patch)
tree8ffa75374dc55951f493618f54b62fe935b32a7c /spec/models
parentf4810647a0e962c7296ba4626b9c6b5e36662efd (diff)
Expect calls to read_attribute depending on cache presence
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index 06d194008c1..bd5319a0c8c 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -51,12 +51,16 @@ describe RedisCacheable do
context 'when there is no cached value' do
it 'reads the attribute' do
+ expect(instance).to receive(:read_attribute).and_call_original
+
expect(subject).to eq(payload[:name])
end
end
context 'when there is a cached value' do
it 'reads the cached value' do
+ expect(instance).not_to receive(:read_attribute)
+
instance.cache_attributes(payload)
expect(subject).to eq(payload[:name])
@@ -81,6 +85,8 @@ describe RedisCacheable do
context 'when there is no cached value' do
it 'reads the attribute' 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)
end
@@ -88,6 +94,8 @@ describe RedisCacheable do
context 'when there is a cached value' do
it 'reads the cached value' do
+ expect(instance).not_to receive(:read_attribute)
+
instance.cache_attributes(time: Time.zone.now)
expect(subject).to be_instance_of(ActiveSupport::TimeWithZone)