diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/lib/api/helpers_spec.rb | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/lib/api/helpers_spec.rb')
-rw-r--r-- | spec/lib/api/helpers_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index b70bcb5ab0d..f8d40d6e181 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -952,6 +952,42 @@ RSpec.describe API::Helpers, feature_category: :shared do end end + describe '#too_many_requests!', :aggregate_failures do + let(:headers) { instance_double(Hash) } + + before do + allow(helper).to receive(:header).and_return(headers) + end + + it 'renders 429' do + expect(helper).to receive(:render_api_error!).with('429 Too Many Requests', 429) + expect(headers).to receive(:[]=).with('Retry-After', 60) + + helper.too_many_requests! + end + + it 'renders 429 with a custom message' do + expect(helper).to receive(:render_api_error!).with('custom message', 429) + expect(headers).to receive(:[]=).with('Retry-After', 60) + + helper.too_many_requests!('custom message') + end + + it 'renders 429 with a custom Retry-After value' do + expect(helper).to receive(:render_api_error!).with('429 Too Many Requests', 429) + expect(headers).to receive(:[]=).with('Retry-After', 120) + + helper.too_many_requests!(retry_after: 2.minutes) + end + + it 'renders 429 without a Retry-After value' do + expect(helper).to receive(:render_api_error!).with('429 Too Many Requests', 429) + expect(headers).not_to receive(:[]=) + + helper.too_many_requests!(retry_after: nil) + end + end + describe '#authenticate_by_gitlab_shell_token!' do include GitlabShellHelpers |