diff options
Diffstat (limited to 'spec/lib/gitlab/process_memory_cache/helper_spec.rb')
-rw-r--r-- | spec/lib/gitlab/process_memory_cache/helper_spec.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/lib/gitlab/process_memory_cache/helper_spec.rb b/spec/lib/gitlab/process_memory_cache/helper_spec.rb index 27d7fd0bdcf..bad4f61282c 100644 --- a/spec/lib/gitlab/process_memory_cache/helper_spec.rb +++ b/spec/lib/gitlab/process_memory_cache/helper_spec.rb @@ -33,13 +33,20 @@ RSpec.describe Gitlab::ProcessMemoryCache::Helper, :use_clean_rails_memory_store end it 'resets the cache when the shared key is missing', :aggregate_failures do - expect(Rails.cache).to receive(:read).with(:cached_content_instance_key).twice.and_return(nil) + allow(Rails.cache).to receive(:read).with(:cached_content_instance_key).and_return(nil) is_expected.to receive(:expensive_computation).thrice.and_return(1, 2, 3) 3.times do |index| expect(subject.cached_content).to eq(index + 1) end end + + it 'does not set the shared timestamp if it is already present', :redis do + subject.clear_cached_content + is_expected.to receive(:expensive_computation).once.and_return(1) + + expect { subject.cached_content }.not_to change { Rails.cache.read(:cached_content_instance_key) } + end end describe '.invalidate_memory_cache' do |