diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 00:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-21 00:08:48 +0300 |
commit | 4d0c47058a89d71d3417ad3bd73781882c8998e8 (patch) | |
tree | 808679f68ca8a8511d12779cf618785d6978be81 /spec/helpers | |
parent | df2eda3f14dccb703bd7054d4ddde7803cb1fe7e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 37bc2b382cb..17e3f8f9c06 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -994,4 +994,56 @@ describe ProjectsHelper do it { is_expected.to eq(grafana_integration.enabled) } end end + + describe '#project_license_name(project)' do + let_it_be(:project) { create(:project) } + let_it_be(:repository) { project.repository } + + subject { project_license_name(project) } + + context 'gitaly is working appropriately' do + it 'returns the license name' do + license = Licensee::License.new('mit') + allow(repository).to receive(:license).and_return(license) + + expect(subject).to eq(license.name) + end + end + + context 'gitaly is unreachable' do + shared_examples 'returns nil and tracks exception' do + it { is_expected.to be_nil } + + it 'tracks the exception' do + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(exception) + ) + + subject + end + end + + before do + allow(repository).to receive(:license).and_raise(exception) + end + + context "Gitlab::Git::CommandError" do + let(:exception) { Gitlab::Git::CommandError } + + it_behaves_like 'returns nil and tracks exception' + end + + context "GRPC::Unavailable" do + let(:exception) { GRPC::Unavailable } + + it_behaves_like 'returns nil and tracks exception' + end + + context "GRPC::DeadlineExceeded" do + let(:exception) { GRPC::DeadlineExceeded } + + it_behaves_like 'returns nil and tracks exception' + end + end + end end |