diff --git a/README.md b/README.md index 0f193e8c..f18f9f30 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Or install it yourself as: Then tell your ruby web application to use rack-attack as a middleware. -a) For __rails__ applications with versions >= 5 it is used by default. For older rails versions you should enable it explicitly: +a) For __rails__ applications with versions >= 5.1 it is used by default. For older rails versions you should enable it explicitly: ```ruby # In config/application.rb diff --git a/lib/rack/attack/railtie.rb b/lib/rack/attack/railtie.rb index 59994f1c..ceed9f7d 100644 --- a/lib/rack/attack/railtie.rb +++ b/lib/rack/attack/railtie.rb @@ -4,7 +4,7 @@ module Rack class Attack class Railtie < ::Rails::Railtie initializer 'rack.attack.middleware', after: :load_config_initializers, before: :build_middleware_stack do |app| - if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5") + if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5.1") middlewares = app.config.middleware operations = middlewares.send(:operations) + middlewares.send(:delete_operations) diff --git a/spec/acceptance/rails_middleware_spec.rb b/spec/acceptance/rails_middleware_spec.rb index 4d27c702..2c69b7e1 100644 --- a/spec/acceptance/rails_middleware_spec.rb +++ b/spec/acceptance/rails_middleware_spec.rb @@ -12,7 +12,7 @@ end end - if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("5") + if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("5.1") it "is used by default" do @app.initialize! assert_equal 1, @app.middleware.count(Rack::Attack) @@ -31,7 +31,7 @@ end end - if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("5") + if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("5.1") it "is not used by default" do @app.initialize! assert_equal 0, @app.middleware.count(Rack::Attack)