We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 88e3ed0 + 031efcd commit 7860a82Copy full SHA for 7860a82
spec/rack_attack_throttle_spec.rb
@@ -85,3 +85,25 @@
85
end
86
87
88
+
89
+describe 'Rack::Attack.throttle with block retuning nil' do
90
+ before do
91
+ @period = 60
92
+ Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
93
+ Rack::Attack.throttle('ip/sec', :limit => 1, :period => @period) { |_| nil }
94
+ end
95
96
+ allow_ok_requests
97
98
+ describe 'a single request' do
99
+ before { get '/', {}, 'REMOTE_ADDR' => '1.2.3.4' }
100
+ it 'should not set the counter' do
101
+ key = "rack::attack:#{Time.now.to_i/@period}:ip/sec:1.2.3.4"
102
+ Rack::Attack.cache.store.read(key).must_equal nil
103
104
105
+ it 'should not populate throttle data' do
106
+ last_request.env['rack.attack.throttle_data'].must_equal nil
107
108
109
+end
0 commit comments