From 564cbedb36693e026a981512197e9e0702c152e0 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Tue, 13 Mar 2018 18:27:19 -0300 Subject: [PATCH] Acceptance test that tracking throttles doesn't actually throttle requests --- spec/acceptance/track_throttle_spec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/acceptance/track_throttle_spec.rb b/spec/acceptance/track_throttle_spec.rb index 900f843..7446ce4 100644 --- a/spec/acceptance/track_throttle_spec.rb +++ b/spec/acceptance/track_throttle_spec.rb @@ -2,7 +2,7 @@ require_relative "../spec_helper" require "timecop" describe "#track with throttle-ish options" do - it "notifies when throttle goes over the limit" do + it "notifies when throttle goes over the limit without actually throttling requests" do Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.track("by ip", limit: 1, period: 60) do |request| @@ -22,16 +22,22 @@ describe "#track with throttle-ish options" do assert_nil notification_matched assert_nil notification_type + assert_equal 200, last_response.status + get "/", {}, "REMOTE_ADDR" => "5.6.7.8" assert_nil notification_matched assert_nil notification_type + assert_equal 200, last_response.status + get "/", {}, "REMOTE_ADDR" => "1.2.3.4" assert_equal "by ip", notification_matched assert_equal :track, notification_type + assert_equal 200, last_response.status + Timecop.travel(60) do notification_matched = nil notification_type = nil @@ -40,6 +46,8 @@ describe "#track with throttle-ish options" do assert_nil notification_matched assert_nil notification_type + + assert_equal 200, last_response.status end end end