diff --git a/app/models/repository.rb b/app/models/repository.rb index ce1238e66d2..2ffd9115372 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -505,10 +505,8 @@ class Repository delegate :tag_names, to: :raw_repository cache_method :tag_names, fallback: [] - delegate :branch_count, to: :raw_repository + delegate :branch_count, :tag_count, to: :raw_repository cache_method :branch_count, fallback: 0 - - delegate :tag_count, to: :raw_repository cache_method :tag_count, fallback: 0 def avatar diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 4526c3194b6..dfa211ec6cd 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1379,7 +1379,10 @@ describe Repository, models: true do describe '#branch_count' do it 'returns the number of branches' do expect(repository.branch_count).to be_an(Integer) + + # NOTE: Until rugged goes away, make sure rugged and gitaly are in sync rugged_count = repository.raw_repository.rugged.branches.count + expect(repository.branch_count).to eq(rugged_count) end end @@ -1387,8 +1390,10 @@ describe Repository, models: true do describe '#tag_count' do it 'returns the number of tags' do expect(repository.tag_count).to be_an(Integer) + # NOTE: Until rugged goes away, make sure rugged and gitaly are in sync rugged_count = repository.raw_repository.rugged.tags.count + expect(repository.tag_count).to eq(rugged_count) end end