Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 09:08:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-30 09:08:49 +0300
commit6305f1dc00870f6e0635e2e850538a00bbd00bda (patch)
tree8a518cae3805b8d7269bfacc8ae60aa441fadb22 /spec/helpers
parent1d388ed855838a2d50588c131f9f23815f148344 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/avatars_helper_spec.rb36
1 files changed, 31 insertions, 5 deletions
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