mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Merge pull request #263 from grzuy/remove_warnings
Fixes warnings in test output
This commit is contained in:
commit
66bb16e97a
5 changed files with 10 additions and 8 deletions
1
Rakefile
1
Rakefile
|
|
@ -10,7 +10,6 @@ namespace :test do
|
|||
|
||||
Rake::TestTask.new(:integration) do |t|
|
||||
t.pattern = "spec/integration/*_spec.rb"
|
||||
t.warning = false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ module Rack
|
|||
# We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
|
||||
# and the MemCache client if using Rails 3.x
|
||||
|
||||
client = store.instance_variable_get(:@data)
|
||||
if store.instance_variable_defined?(:@data)
|
||||
client = store.instance_variable_get(:@data)
|
||||
end
|
||||
|
||||
if ACTIVE_SUPPORT_WRAPPER_CLASSES.include?(store.class.to_s) && ACTIVE_SUPPORT_CLIENTS.include?(client.class.to_s)
|
||||
client
|
||||
else
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ describe 'Rack::Attack.Fail2Ban' do
|
|||
|
||||
it 'resets fail count' do
|
||||
key = "rack::attack:#{Time.now.to_i/@findtime}:fail2ban:count:1.2.3.4"
|
||||
@cache.store.read(key).must_equal nil
|
||||
assert_nil @cache.store.read(key)
|
||||
end
|
||||
|
||||
it 'IP is not banned' do
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ describe Rack::Attack::Cache do
|
|||
store.write(@key, "foobar", :expires_in => @expires_in)
|
||||
@cache.read('cache-test-key').must_equal "foobar"
|
||||
store.delete(@key)
|
||||
@cache.read('cache-test-key').must_equal nil
|
||||
assert_nil @cache.read('cache-test-key')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ describe Rack::Attack::Cache do
|
|||
period_key, _ = @cache.send(:key_and_expiry, 'cache-test-key', period)
|
||||
store.read(period_key).to_i.must_equal 1
|
||||
@cache.reset_count(unprefixed_key, period)
|
||||
store.read(period_key).must_equal nil
|
||||
assert_nil store.read(period_key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ describe 'Rack::Attack.throttle with block retuning nil' do
|
|||
before { get '/', {}, 'REMOTE_ADDR' => '1.2.3.4' }
|
||||
it 'should not set the counter' do
|
||||
key = "rack::attack:#{Time.now.to_i/@period}:ip/sec:1.2.3.4"
|
||||
Rack::Attack.cache.store.read(key).must_equal nil
|
||||
assert_nil Rack::Attack.cache.store.read(key)
|
||||
end
|
||||
|
||||
it 'should not populate throttle data' do
|
||||
last_request.env['rack.attack.throttle_data'].must_equal nil
|
||||
assert_nil last_request.env['rack.attack.throttle_data']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue