diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 09:08:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 09:08:13 +0000 |
commit | 8e94dad32b10edebf79285c083176c2b7005ef64 (patch) | |
tree | 3bb66395f2962063ca0d20f98b35ac852d801c7e /spec/lib/banzai | |
parent | ab128cc125f9db0c3a1bd48845f90c3d61ef42c9 (diff) | |
download | gitlab-ce-8e94dad32b10edebf79285c083176c2b7005ef64.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/filter/repository_link_filter_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/repository_link_filter_spec.rb b/spec/lib/banzai/filter/repository_link_filter_spec.rb index cf73c77ecb8..f093a5b0a79 100644 --- a/spec/lib/banzai/filter/repository_link_filter_spec.rb +++ b/spec/lib/banzai/filter/repository_link_filter_spec.rb @@ -149,6 +149,34 @@ describe Banzai::Filter::RepositoryLinkFilter do end shared_examples :valid_repository do + it 'handles Gitaly unavailable exceptions gracefully' do + allow_next_instance_of(Gitlab::GitalyClient::BlobService) do |blob_service| + allow(blob_service).to receive(:get_blob_types).and_raise(GRPC::Unavailable) + end + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(GRPC::Unavailable), project_id: project.id + ) + doc = "" + expect { doc = filter(link('doc/api/README.md')) }.not_to raise_error + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" + end + + it 'handles Gitaly timeout exceptions gracefully' do + allow_next_instance_of(Gitlab::GitalyClient::BlobService) do |blob_service| + allow(blob_service).to receive(:get_blob_types).and_raise(GRPC::DeadlineExceeded) + end + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(GRPC::DeadlineExceeded), project_id: project.id + ) + doc = "" + expect { doc = filter(link('doc/api/README.md')) }.not_to raise_error + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" + end + it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) expect(doc.at_css('a')['href']) |