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:
Diffstat (limited to 'spec/requests/api/api_spec.rb')
-rw-r--r--spec/requests/api/api_spec.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/requests/api/api_spec.rb b/spec/requests/api/api_spec.rb
index 35851fff6c8..219c7dbdbc5 100644
--- a/spec/requests/api/api_spec.rb
+++ b/spec/requests/api/api_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe API::API, feature_category: :authentication_and_authorization do
+RSpec.describe API::API, feature_category: :system_access do
include GroupAPIHelpers
describe 'Record user last activity in after hook' do
@@ -359,4 +359,26 @@ RSpec.describe API::API, feature_category: :authentication_and_authorization do
end
end
end
+
+ describe 'Handle Gitlab::Git::ResourceExhaustedError exception' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository, creator: user) }
+
+ before do
+ project.add_maintainer(user)
+ allow(Gitlab::GitalyClient).to receive(:call).with(any_args).and_raise(
+ Gitlab::Git::ResourceExhaustedError.new("Upstream Gitaly has been exhausted. Try again later", 50)
+ )
+ end
+
+ it 'returns 429 status with exhausted' do
+ get api("/projects/#{project.id}/repository/commits", user)
+
+ expect(response).to have_gitlab_http_status(:too_many_requests)
+ expect(response.headers['Retry-After']).to be(50)
+ expect(json_response).to eql(
+ 'message' => 'Upstream Gitaly has been exhausted. Try again later'
+ )
+ end
+ end
end