diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/controllers/import | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/controllers/import')
-rw-r--r-- | spec/controllers/import/bitbucket_controller_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb index 0427715d1ac..91e43adc472 100644 --- a/spec/controllers/import/bitbucket_controller_spec.rb +++ b/spec/controllers/import/bitbucket_controller_spec.rb @@ -252,6 +252,30 @@ RSpec.describe Import::BitbucketController do end end end + + context "when exceptions occur" do + shared_examples "handles exceptions" do + it "logs an exception" do + expect(Bitbucket::Client).to receive(:new).and_raise(error) + expect(controller).to receive(:log_exception) + + post :create, format: :json + end + end + + context "for OAuth2 errors" do + let(:fake_response) { double('Faraday::Response', headers: {}, body: '', status: 403) } + let(:error) { OAuth2::Error.new(OAuth2::Response.new(fake_response)) } + + it_behaves_like "handles exceptions" + end + + context "for Bitbucket errors" do + let(:error) { Bitbucket::Error::Unauthorized.new("error") } + + it_behaves_like "handles exceptions" + end + end end context 'user has chosen an existing nested namespace and name for the project' do |