summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-01-21 18:19:18 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-01-21 18:19:18 +0100
commit0689663487c66d21aa83da0830bc2c042f89e6e8 (patch)
tree4973e074542b986b2bfd9f7c36dd7608ccb4b1e9 /spec
parentd21d8e57d345cf783a7e66fd2a20dae6ec1dff84 (diff)
downloadgitlab-ce-0689663487c66d21aa83da0830bc2c042f89e6e8.tar.gz
Use branch_count in Repository#has_visible_content?
Gitlab::Git::Repository#branch_count is a tad faster than the previous setup. See gitlab-org/gitlab_git!62 for more information.
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index afbf62035ac..c484ae8fc8c 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -219,4 +219,24 @@ describe Repository, models: true do
end
end
end
+
+ describe '#has_visible_content?' do
+ subject { repository.has_visible_content? }
+
+ describe 'when there are no branches' do
+ before do
+ allow(repository.raw_repository).to receive(:branch_count).and_return(0)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+
+ describe 'when there are branches' do
+ before do
+ allow(repository.raw_repository).to receive(:branch_count).and_return(3)
+ end
+
+ it { is_expected.to eq(true) }
+ end
+ end
end