diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-06-25 19:26:29 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-06-25 19:30:05 -0300 |
commit | cad8bb187deabcb4fc8ee9b58442845658205ee5 (patch) | |
tree | 984a5bba58067d85f06746f2606de5769cd476d1 /spec | |
parent | 87b468c254e3e1e3b6b1d86e003f1f90a39935a2 (diff) | |
download | gitlab-ce-cad8bb187deabcb4fc8ee9b58442845658205ee5.tar.gz |
Parse the cached value when the it is false
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/json_cache_spec.rb | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb index 59160741c45..39cdd42088e 100644 --- a/spec/lib/gitlab/json_cache_spec.rb +++ b/spec/lib/gitlab/json_cache_spec.rb @@ -129,19 +129,52 @@ describe Gitlab::JsonCache do .with(expanded_key) .and_return(nil) + expect(ActiveSupport::JSON).not_to receive(:decode) expect(cache.read(key)).to be_nil end - context 'when the cached value is a boolean' do + context 'when the cached value is true' do it 'parses the cached value' do allow(backend).to receive(:read) .with(expanded_key) .and_return(true) + expect(ActiveSupport::JSON).to receive(:decode).with("true").and_call_original expect(cache.read(key, BroadcastMessage)).to eq(true) end end + context 'when the cached value is false' do + it 'parses the cached value' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return(false) + + expect(ActiveSupport::JSON).to receive(:decode).with("false").and_call_original + expect(cache.read(key, BroadcastMessage)).to eq(false) + end + end + + context 'when the cached value is a JSON true value' do + it 'parses the cached value' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return("true") + + expect(cache.read(key, BroadcastMessage)).to eq(true) + end + end + + context 'when the cached value is a JSON false value' do + it 'parses the cached value' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return("false") + + expect(cache.read(key, BroadcastMessage)).to eq(false) + end + end + context 'when the cached value is a hash' do it 'parses the cached value' do allow(backend).to receive(:read) |