summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-12 14:43:05 +0200
committerMatija Čupić <matteeyah@gmail.com>2018-05-12 14:43:05 +0200
commitb1fcac85bd0f0904c277fb917790a253777d0e8b (patch)
treea834448e80467b1f8c1984d164747cb8c3c32fce
parent20cfc3fccec75562bdb514587d2c9f7b59554c07 (diff)
downloadgitlab-ce-b1fcac85bd0f0904c277fb917790a253777d0e8b.tar.gz
Make #cached_attr_reader and #cached_attr_time_reader specs Redis based
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index ca09bf75216..cb81ded7c48 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -42,7 +42,7 @@ describe RedisCacheable do
end
end
- describe '#cached_attr_reader' do
+ describe '#cached_attr_reader', :clean_gitlab_redis_shared_state do
subject { instance.name }
before do
@@ -51,7 +51,6 @@ describe RedisCacheable do
context 'when there is no cached value' do
it 'checks the cached value first then reads the attribute' do
- expect(instance).to receive(:cached_attribute).and_return(nil)
expect(instance).to receive(:read_attribute).and_return(payload[:name])
expect(subject).to eq(payload[:name])
@@ -60,15 +59,14 @@ describe RedisCacheable do
context 'when there is a cached value' do
it 'reads the cached value' do
- expect(instance).to receive(:cached_attribute).and_return(payload[:name])
- expect(instance).not_to receive(:read_attribute)
+ instance.cache_attributes(payload)
expect(subject).to eq(payload[:name])
end
end
end
- describe '#cached_attr_time_reader' do
+ describe '#cached_attr_time_reader', :clean_gitlab_redis_shared_state do
subject { instance.time }
before do
@@ -77,7 +75,6 @@ describe RedisCacheable do
context 'when there is no cached value' do
it 'checks the cached value first then reads the attribute' do
- expect(instance).to receive(:cached_attribute).and_return(nil)
expect(instance).to receive(:read_attribute).and_return(Time.zone.now)
expect(subject).to be_instance_of(ActiveSupport::TimeWithZone)
@@ -87,8 +84,7 @@ describe RedisCacheable do
context 'when there is a cached value' do
it 'reads the cached value' do
- expect(instance).to receive(:cached_attribute).and_return(Time.zone.now.to_s)
- expect(instance).not_to receive(:read_attribute)
+ instance.cache_attributes(time: Time.zone.now)
expect(subject).to be_instance_of(ActiveSupport::TimeWithZone)
expect(subject).to be_within(1.minute).of(Time.zone.now)