summaryrefslogtreecommitdiff
path: root/spec/models/repository_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-10-01 19:45:44 -0700
committerStan Hu <stanhu@gmail.com>2017-10-01 22:14:11 -0700
commit6188e449dee43a18b9cec1a7bb5a2cd7aa17b6f7 (patch)
tree96ee8f0098786b9489ee025cdbd28747ad3f0198 /spec/models/repository_spec.rb
parent6c33fb846683ca9213dadaa79b0f32f482ebc0bf (diff)
downloadgitlab-ce-6188e449dee43a18b9cec1a7bb5a2cd7aa17b6f7.tar.gz
Fix pushes to an empty repository not invalidating has_visible_content? cache
`Repository#has_visible_content?` used to rely on the cached count of local branches, but since it is now an independently cached value it needs to be invalidated on its own. Closes #38646
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r--spec/models/repository_spec.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index ab81d39691b..3b8ae4d3fd1 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1272,6 +1272,7 @@ describe Repository do
allow(repository).to receive(:empty?).and_return(true)
expect(cache).to receive(:expire).with(:empty?)
+ expect(cache).to receive(:expire).with(:has_visible_content?)
repository.expire_emptiness_caches
end
@@ -1280,6 +1281,7 @@ describe Repository do
allow(repository).to receive(:empty?).and_return(false)
expect(cache).not_to receive(:expire).with(:empty?)
+ expect(cache).not_to receive(:expire).with(:has_visible_content?)
repository.expire_emptiness_caches
end
@@ -1609,7 +1611,7 @@ describe Repository do
describe '#expire_branches_cache' do
it 'expires the cache' do
expect(repository).to receive(:expire_method_caches)
- .with(%i(branch_names branch_count))
+ .with(%i(branch_names branch_count has_visible_content?))
.and_call_original
repository.expire_branches_cache
@@ -1888,6 +1890,15 @@ describe Repository do
repository.expire_all_method_caches
end
+
+ it 'all cache_method definitions are in the lists of method caches' do
+ methods = repository.methods.map do |method|
+ match = /^_uncached_(.*)/.match(method)
+ match[1].to_sym if match
+ end.compact
+
+ expect(methods).to match_array(Repository::CACHED_METHODS + Repository::MEMOIZED_CACHED_METHODS)
+ end
end
describe '#file_on_head' do