expect(DecidimApp::RackAttack::Throttling.max_requests).to eq(100)
expect(DecidimApp::RackAttack::Throttling.period).to eq(60)
end
# TODO: Rack Attack investigate failing spec
# it "successful for 100 requests, then blocks the user" do
# 100.times do
# get decidim.root_path, params: {}, headers: headers
# expect(response).to have_http_status(:ok)
# end
#
# get decidim.root_path, params: {}, headers: headers
# expect(response).to have_http_status(:too_many_requests)
# expect(response.body).to include("Your connection has been slowed because server received too many requests.")#
#
# travel_to(1.minute.from_now) do
# get decidim.root_path, params: {}, headers: headers
# expect(response).to have_http_status(:ok)
# end
# end
it "successful for 99 requests" do
99.times do
it "successful for 100 requests, then blocks the user" do
100.times do
get decidim.root_path, params: {}, headers: headers
expect(response).to have_http_status(:ok)
end
get decidim.root_path, params: {}, headers: headers
expect(response).to have_http_status(:too_many_requests)
expect(response.body).to include("Your connection has been slowed because server received too many requests.")#
travel_to(1.minute.from_now) do
get decidim.root_path, params: {}, headers: headers
expect(response).to have_http_status(:ok)
end
end
https://api.github.com/OpenSourcePolitics/decidim-cd44/blob/4c9294be52073499ffa9d25e535a13e413145501/spec/lib/decidim_app/rack_attack_spec.rb#L78