diff options
-rw-r--r-- | lib/gitlab/repository_cache_adapter.rb | 8 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index bd0e51cbfe5..160e3d13b43 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -136,6 +136,8 @@ module Gitlab clear_memoization(memoizable_name(name)) end + + expire_request_store_method_caches(methods) end private @@ -144,6 +146,12 @@ module Gitlab "#{name.to_s.tr('?!', '')}" end + def expire_request_store_method_caches(methods) + methods.each do |name| + request_store_cache.expire(name) + end + end + # All cached repository methods depend on the existence of a Git repository, # so if the repository doesn't exist, we already know not to call it. def fallback_early?(method_name) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index b2869104e02..7e1b7c35517 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1757,12 +1757,19 @@ describe Repository do describe '#expire_exists_cache' do let(:cache) { repository.send(:cache) } + let(:request_store_cache) { repository.send(:request_store_cache) } it 'expires the cache' do expect(cache).to receive(:expire).with(:exists?) repository.expire_exists_cache end + + it 'expires the request store cache', :request_store do + expect(request_store_cache).to receive(:expire).with(:exists?) + + repository.expire_exists_cache + end end describe '#xcode_project?' do |