Commit 74e5ec19 authored by Stan Hu's avatar Stan Hu

Fix failing ./spec/lib/backup/repository_spec.rb by clearing the memoized value

parent b1f15dfa
......@@ -331,6 +331,7 @@ class Repository
return unless empty?
expire_method_caches(%i(has_visible_content?))
raw_repository.expire_has_local_branches_cache
end
def lookup_cache
......
......@@ -232,6 +232,10 @@ module Gitlab
end
end
def expire_has_local_branches_cache
clear_memoization(:has_local_branches)
end
def has_local_branches?
strong_memoize(:has_local_branches) do
uncached_has_local_branches?
......
......@@ -463,13 +463,14 @@ describe Gitlab::Git::Repository, seed_helper: true do
it 'returns false when there are no branches' do
# Sanity check
expect(repository.uncached_has_local_branches?).to eq(true)
expect(repository.has_local_branches?).to eq(true)
FileUtils.rm_rf(File.join(repository.path, 'packed-refs'))
heads_dir = File.join(repository.path, 'refs/heads')
FileUtils.rm_rf(heads_dir)
FileUtils.mkdir_p(heads_dir)
repository.expire_has_local_branches_cache
expect(repository.has_local_branches?).to eq(false)
end
end
......
......@@ -1437,6 +1437,12 @@ describe Repository do
repository.expire_emptiness_caches
end
it 'expires the memoized repository cache' do
allow(repository.raw_repository).to receive(:expire_has_local_branches_cache).and_call_original
repository.expire_emptiness_caches
end
end
describe 'skip_merges option' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment