summaryrefslogtreecommitdiff
path: root/spec/lib/banzai
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 09:08:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 09:08:13 +0000
commit8e94dad32b10edebf79285c083176c2b7005ef64 (patch)
tree3bb66395f2962063ca0d20f98b35ac852d801c7e /spec/lib/banzai
parentab128cc125f9db0c3a1bd48845f90c3d61ef42c9 (diff)
downloadgitlab-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.rb28
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'])