diff options
Diffstat (limited to 'spec/controllers/repositories/git_http_controller_spec.rb')
-rw-r--r-- | spec/controllers/repositories/git_http_controller_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/controllers/repositories/git_http_controller_spec.rb b/spec/controllers/repositories/git_http_controller_spec.rb index 04d5008cb34..b5cd14154a3 100644 --- a/spec/controllers/repositories/git_http_controller_spec.rb +++ b/spec/controllers/repositories/git_http_controller_spec.rb @@ -7,12 +7,33 @@ RSpec.describe Repositories::GitHttpController do let_it_be(:personal_snippet) { create(:personal_snippet, :public, :repository) } let_it_be(:project_snippet) { create(:project_snippet, :public, :repository, project: project) } + shared_examples 'handles unavailable Gitaly' do + let(:params) { super().merge(service: 'git-upload-pack') } + + before do + request.headers.merge! auth_env(user.username, user.password, nil) + end + + context 'when Gitaly is unavailable' do + it 'responds with a 503 message' do + expect(Gitlab::GitalyClient).to receive(:call).and_raise(GRPC::Unavailable) + + get :info_refs, params: params + + expect(response).to have_gitlab_http_status(:service_unavailable) + expect(response.body).to eq('The git server, Gitaly, is not available at this time. Please contact your administrator.') + end + end + end + context 'when repository container is a project' do it_behaves_like Repositories::GitHttpController do let(:container) { project } let(:user) { project.owner } let(:access_checker_class) { Gitlab::GitAccess } + it_behaves_like 'handles unavailable Gitaly' + describe 'POST #git_upload_pack' do before do allow(controller).to receive(:verify_workhorse_api!).and_return(true) @@ -84,6 +105,8 @@ RSpec.describe Repositories::GitHttpController do let(:container) { personal_snippet } let(:user) { personal_snippet.author } let(:access_checker_class) { Gitlab::GitAccessSnippet } + + it_behaves_like 'handles unavailable Gitaly' end end @@ -92,6 +115,8 @@ RSpec.describe Repositories::GitHttpController do let(:container) { project_snippet } let(:user) { project_snippet.author } let(:access_checker_class) { Gitlab::GitAccessSnippet } + + it_behaves_like 'handles unavailable Gitaly' end end end |