mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
Merge branch 'patch-2' into patch-3
Conflicts: lib/rack/attack/store_proxy.rb
This commit is contained in:
commit
1c0bc3da4d
2 changed files with 18 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ module Rack
|
||||||
class DalliProxy < SimpleDelegator
|
class DalliProxy < SimpleDelegator
|
||||||
def initialize(client)
|
def initialize(client)
|
||||||
super(client)
|
super(client)
|
||||||
|
stub_with_method_on_older_clients
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(key)
|
def read(key)
|
||||||
|
|
@ -95,6 +96,16 @@ module Rack
|
||||||
end
|
end
|
||||||
rescue Dalli::DalliError
|
rescue Dalli::DalliError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# So we support Dalli < 2.7.0
|
||||||
|
def stub_with_method_on_older_clients
|
||||||
|
unless __getobj__.respond_to?(:with)
|
||||||
|
def __getobj__.with; yield self; end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -143,4 +143,11 @@ describe Rack::Attack::Cache do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "given an older Dalli::Client" do
|
||||||
|
it "should stub #with" do
|
||||||
|
proxy = Rack::Attack::StoreProxy::DalliProxy.new(Class.new)
|
||||||
|
proxy.must_respond_to :with
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue