Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-09-01 22:16:26 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-09-01 22:16:26 +0300
commita9e28b3dfbbdaf4c0bba4cb5a4f7952ddca0a792 (patch)
tree0453f07d592cae8a3406988a7ede470e556ae47b /spec
parenta26771926111b4d7bba13f974666aac85dab7a92 (diff)
parentd326d3428da89b943bb5f1d4d396f21b3e999ff7 (diff)
Merge branch 'sh-reload-find-branch' into 'master'
Optimize branch lookups and force a repository reload for Repository#find_branch See merge request !6087
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 1fea50ad42c..812c72c48cb 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -382,6 +382,24 @@ describe Repository, models: true do
end
end
+ describe '#find_branch' do
+ it 'loads a branch with a fresh repo' do
+ expect(Gitlab::Git::Repository).to receive(:new).twice.and_call_original
+
+ 2.times do
+ expect(repository.find_branch('feature')).not_to be_nil
+ end
+ end
+
+ it 'loads a branch with a cached repo' do
+ expect(Gitlab::Git::Repository).to receive(:new).once.and_call_original
+
+ 2.times do
+ expect(repository.find_branch('feature', fresh_repo: false)).not_to be_nil
+ end
+ end
+ end
+
describe '#rm_branch' do
let(:old_rev) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } # git rev-parse feature
let(:blank_sha) { '0000000000000000000000000000000000000000' }