Commit 2f96c803 authored by Imre Farkas's avatar Imre Farkas

Fix Ruby 2.7 kwargs deprecation warning in rack_attack_spec

parent 79d36849
...@@ -23,7 +23,7 @@ RSpec.describe 'Rack Attack EE throttles' do ...@@ -23,7 +23,7 @@ RSpec.describe 'Rack Attack EE throttles' do
} }
end end
let(:post_args) { post_args_with_token_headers(path, oauth_token_headers(token)) } let(:post_args) { { headers: oauth_token_headers(token) } }
before do before do
stub_application_setting(settings_to_set) stub_application_setting(settings_to_set)
...@@ -39,29 +39,29 @@ RSpec.describe 'Rack Attack EE throttles' do ...@@ -39,29 +39,29 @@ RSpec.describe 'Rack Attack EE throttles' do
it 'rejects requests over the rate limit' do it 'rejects requests over the rate limit' do
# At first, allow requests under the rate limit. # At first, allow requests under the rate limit.
requests_per_period.times do requests_per_period.times do
post(*post_args) post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
# the last straw # the last straw
expect_rejection { post(*post_args) } expect_rejection { post(path, **post_args) }
end end
it 'allows requests after throttling and then waiting for the next period' do it 'allows requests after throttling and then waiting for the next period' do
requests_per_period.times do requests_per_period.times do
post(*post_args) post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
expect_rejection { post(*post_args) } expect_rejection { post(path, **post_args) }
Timecop.travel(period.from_now) do Timecop.travel(period.from_now) do
requests_per_period.times do requests_per_period.times do
post(*post_args) post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
expect_rejection { post(*post_args) } expect_rejection { post(path, **post_args) }
end end
end end
end end
...@@ -72,12 +72,12 @@ RSpec.describe 'Rack Attack EE throttles' do ...@@ -72,12 +72,12 @@ RSpec.describe 'Rack Attack EE throttles' do
it 'allows requests over the rate limit' do it 'allows requests over the rate limit' do
# At first, allow requests under the rate limit. # At first, allow requests under the rate limit.
requests_per_period.times do requests_per_period.times do
post(*post_args) post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
# requests still allowed # requests still allowed
post(*post_args) post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module RackAttackSpecHelpers module RackAttackSpecHelpers
def post_args_with_token_headers(url, token_headers)
[url, params: nil, headers: token_headers]
end
def api_get_args_with_token_headers(partial_url, token_headers) def api_get_args_with_token_headers(partial_url, token_headers)
["/api/#{API::API.version}#{partial_url}", params: nil, headers: token_headers] ["/api/#{API::API.version}#{partial_url}", params: nil, headers: token_headers]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment