diff options
author | Rémy Coutable <remy@rymai.me> | 2018-03-05 18:26:44 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-05 18:26:44 +0300 |
commit | e02502f998bee8105d8171cd0df9dd8c1689088d (patch) | |
tree | 2043126193850ebddce64d5e5aefdbf07888fc41 /spec/lib | |
parent | df23494cd98f12e4341c5cc12764364404eabfad (diff) | |
parent | 0a4ee10eda01e23ddea0e6b4f80f61df3ffaabde (diff) |
Merge branch '37430-projects-comparecontroller-show-is-calling-gitaly-n-1-times-per-request' into 'master'
Resolve "Projects::CompareController#show is calling Gitaly n+1 times per request"
Closes #37430
See merge request gitlab-org/gitlab-ce!17439
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/git/blob_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index a6341cd509b..67d898e787e 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -500,4 +500,33 @@ describe Gitlab::Git::Blob, seed_helper: true do end end end + + describe '#load_all_data!' do + let(:full_data) { 'abcd' } + let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abc') } + + subject { blob.load_all_data!(repository) } + + it 'loads missing data' do + expect(Gitlab::GitalyClient).to receive(:migrate) + .with(:git_blob_load_all_data).and_return(full_data) + + subject + + expect(blob.data).to eq(full_data) + end + + context 'with a fully loaded blob' do + let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: full_data) } + + it "doesn't perform any loading" do + expect(Gitlab::GitalyClient).not_to receive(:migrate) + .with(:git_blob_load_all_data) + + subject + + expect(blob.data).to eq(full_data) + end + end + end end |