style: fix Style/BlockDelimiters cop check

This commit is contained in:
Gonzalo Rodriguez 2019-08-02 15:24:17 -03:00
parent c0328707b1
commit 8fafa7602b
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
5 changed files with 9 additions and 10 deletions

View file

@ -37,6 +37,7 @@ Security:
Style/BlockDelimiters:
Enabled: true
IgnoredMethods: [] # Workaround rubocop bug: https://github.com/rubocop-hq/rubocop/issues/6179
Style/BracesAroundHashParameters:
Enabled: true

View file

@ -138,10 +138,10 @@ module Rack
@anonymous_safelists = []
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blocklisted_response = lambda { |_env| [403, { 'Content-Type' => 'text/plain' }, ["Forbidden\n"]] }
@throttled_response = lambda { |env|
@throttled_response = lambda do |env|
retry_after = (env['rack.attack.match_data'] || {})[:period]
[429, { 'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s }, ["Retry later\n"]]
}
end
def initialize(app)
@app = app

View file

@ -15,8 +15,6 @@ if defined?(::ConnectionPool) && defined?(::Dalli)
Rack::Attack.cache.store.clear
end
it_works_for_cache_backed_features(fetch_from_store: ->(key) {
Rack::Attack.cache.store.read(key)
})
it_works_for_cache_backed_features(fetch_from_store: ->(key) { Rack::Attack.cache.store.read(key) })
end
end

View file

@ -17,8 +17,8 @@ if defined?(::Dalli) && defined?(::ConnectionPool)
Rack::Attack.cache.store.with { |client| client.flush_all }
end
it_works_for_cache_backed_features(fetch_from_store: ->(key) {
Rack::Attack.cache.store.with { |client| client.fetch(key) }
})
it_works_for_cache_backed_features(
fetch_from_store: ->(key) { Rack::Attack.cache.store.with { |client| client.fetch(key) } }
)
end
end

View file

@ -22,9 +22,9 @@ describe 'Rack::Attack' do
Rack::Attack.blocklist("ip #{@bad_ip}") { |req| req.ip == @bad_ip }
end
it('has a blocklist') {
it 'has a blocklist' do
Rack::Attack.blocklists.key?("ip #{@bad_ip}").must_equal true
}
end
describe "a bad request" do
before { get '/', {}, 'REMOTE_ADDR' => @bad_ip }