summaryrefslogtreecommitdiff
path: root/spec/models/concerns
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-06 19:01:23 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-06 19:01:41 +0100
commitb75fa80eaae13b4474bac5453420988e14903c4f (patch)
treefd3412da1cecc2bf69bdad461b581e4812f62cec /spec/models/concerns
parent2d2a4ede1f09f7ca98508ad586e56a8cb7285fe3 (diff)
downloadgitlab-ce-b75fa80eaae13b4474bac5453420988e14903c4f.tar.gz
Check return value in RedisCacheable#cached_attribute spec
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index d6a7d7d1462..ffb35079149 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -8,14 +8,19 @@ describe RedisCacheable do
end
describe '#cached_attribute' do
- subject { model.cached_attribute(:anything) }
+ let(:payload) { { attribute: 'value' } }
+
+ subject { model.cached_attribute(payload.keys.first) }
it 'gets the cache attribute' do
+ expect(model).to receive(:cache_attribute_key).and_return('key')
+
Gitlab::Redis::SharedState.with do |redis|
- expect(redis).to receive(:get).with(model.send(:cache_attribute_key))
+ expect(redis).to receive(:get).with('key')
+ .and_return(payload.to_json)
end
- subject
+ expect(subject).to eq(payload.values.first)
end
end