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
}
end
let(:post_args) { post_args_with_token_headers(path, oauth_token_headers(token)) }
let(:post_args) { { headers: oauth_token_headers(token) } }
before do
stub_application_setting(settings_to_set)
......@@ -39,29 +39,29 @@ RSpec.describe 'Rack Attack EE throttles' do
it 'rejects requests over the rate limit' do
# At first, allow requests under the rate limit.
requests_per_period.times do
post(*post_args)
post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok)
end
# the last straw
expect_rejection { post(*post_args) }
expect_rejection { post(path, **post_args) }
end
it 'allows requests after throttling and then waiting for the next period' do
requests_per_period.times do
post(*post_args)
post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok)
end
expect_rejection { post(*post_args) }
expect_rejection { post(path, **post_args) }
Timecop.travel(period.from_now) do
requests_per_period.times do
post(*post_args)
post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok)
end
expect_rejection { post(*post_args) }
expect_rejection { post(path, **post_args) }
end
end
end
......@@ -72,12 +72,12 @@ RSpec.describe 'Rack Attack EE throttles' do
it 'allows requests over the rate limit' do
# At first, allow requests under the rate limit.
requests_per_period.times do
post(*post_args)
post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok)
end
# requests still allowed
post(*post_args)
post(path, **post_args)
expect(response).to have_gitlab_http_status(:ok)
end
end
......
# frozen_string_literal: true
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)
["/api/#{API::API.version}#{partial_url}", params: nil, headers: token_headers]
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