diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-07 19:20:45 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-07 19:20:45 +0000 |
commit | fb89f41721edecc1408ab20d1c0cfe5bb1a00a94 (patch) | |
tree | af0fe99ff268093b9ee9ca755616a5f437d085a5 /spec | |
parent | 714d8e95f6de31ed2686f1b2ca05cb5d1f68c878 (diff) | |
parent | cf25ef38d2e58a46c4a09e4bc416618afd676c78 (diff) | |
download | gitlab-ce-fb89f41721edecc1408ab20d1c0cfe5bb1a00a94.tar.gz |
Merge branch 'fix/cache-gitaly-find-commits' into 'master'
Cache Gitaly FindCommit RPC response
See merge request gitlab-org/gitlab-ce!16949
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/commit_service_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 3722a91c050..001c4d3e10a 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -166,6 +166,32 @@ describe Gitlab::GitalyClient::CommitService do described_class.new(repository).find_commit(revision) end + + describe 'caching', :request_store do + let(:commit_dbl) { double(id: 'f01b' * 10) } + + context 'when passed revision is a branch name' do + it 'calls Gitaly' do + expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commit).twice.and_return(double(commit: commit_dbl)) + + commit = nil + 2.times { commit = described_class.new(repository).find_commit('master') } + + expect(commit).to eq(commit_dbl) + end + end + + context 'when passed revision is a commit ID' do + it 'returns a cached commit' do + expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commit).once.and_return(double(commit: commit_dbl)) + + commit = nil + 2.times { commit = described_class.new(repository).find_commit('f01b' * 10) } + + expect(commit).to eq(commit_dbl) + end + end + end end describe '#patch' do |