mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Make HTTP::Cookie#expired? optionally take a time.
This commit is contained in:
parent
d8be652a92
commit
1fcf008cf0
2 changed files with 4 additions and 2 deletions
|
|
@ -344,9 +344,9 @@ class HTTP::Cookie
|
|||
end
|
||||
end
|
||||
|
||||
def expired?
|
||||
def expired?(time = Time.now)
|
||||
return false unless @expires
|
||||
Time.now > @expires
|
||||
time > @expires
|
||||
end
|
||||
|
||||
def expire
|
||||
|
|
|
|||
|
|
@ -451,6 +451,8 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
cookie = HTTP::Cookie.new(cookie_values)
|
||||
|
||||
assert_equal false, cookie.expired?
|
||||
assert_equal true, cookie.expired?(cookie.expires + 1)
|
||||
assert_equal false, cookie.expired?(cookie.expires - 1)
|
||||
cookie.expire
|
||||
assert_equal true, cookie.expired?
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue