summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-04-28 14:12:29 +0200
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-04-28 14:12:29 +0200
commit573d0989110ccb0630481f416d1a4f8fd05ee608 (patch)
tree0cd52e306c22e570ef895440b21c605813af2b24
parenta998710a3b2d4d2f5fa7dbdaf4ae468cd304730c (diff)
downloadgitlab-ce-gitaly-branch-tag-count.tar.gz
-rw-r--r--app/models/repository.rb4
-rw-r--r--spec/models/repository_spec.rb5
2 files changed, 6 insertions, 3 deletions
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