diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-09-01 19:16:26 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-09-01 19:16:26 +0000 |
commit | a9e28b3dfbbdaf4c0bba4cb5a4f7952ddca0a792 (patch) | |
tree | 0453f07d592cae8a3406988a7ede470e556ae47b /spec | |
parent | a26771926111b4d7bba13f974666aac85dab7a92 (diff) | |
parent | d326d3428da89b943bb5f1d4d396f21b3e999ff7 (diff) | |
download | gitlab-ce-a9e28b3dfbbdaf4c0bba4cb5a4f7952ddca0a792.tar.gz |
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.rb | 18 |
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' } |