From 6305f1dc00870f6e0635e2e850538a00bbd00bda Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 30 Jan 2020 06:08:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/helpers/avatars_helper_spec.rb | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'spec/helpers') diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb index 8b6817efcc4..2a030742cb9 100644 --- a/spec/helpers/avatars_helper_spec.rb +++ b/spec/helpers/avatars_helper_spec.rb @@ -22,15 +22,41 @@ describe AvatarsHelper do end end - context 'when providing a project' do - it_behaves_like 'resource with a default avatar', 'project' do - let(:resource) { create(:project, name: 'foo') } - let(:helper_args) { [resource] } + shared_examples 'Gitaly exception handling' do + before do + allow(resource).to receive(:avatar_url).and_raise(error_class) end + it 'handles Gitaly exception gracefully' do + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(error_class), source_type: 'Project', source_id: resource.id + ) + expect { project_icon(resource) }.not_to raise_error + end + + it_behaves_like 'resource with a default avatar', 'project' + end + + context 'when providing a project' do + let(:helper_args) { [resource] } + let(:resource) { create(:project, name: 'foo') } + + it_behaves_like 'resource with a default avatar', 'project' + it_behaves_like 'resource with a custom avatar', 'project' do let(:resource) { create(:project, :public, avatar: File.open(uploaded_image_temp_path)) } - let(:helper_args) { [resource] } + end + + context 'when Gitaly is unavailable' do + let(:error_class) { GRPC::Unavailable } + + include_examples 'Gitaly exception handling' + end + + context 'when Gitaly request is taking too long' do + let(:error_class) { GRPC::DeadlineExceeded } + + include_examples 'Gitaly exception handling' end end -- cgit v1.2.1