mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
DEV: correct implementation of expiry api
Previously we were always hard-coding expiry, this allows the secure session to correctly handle custom expiry times Also adds a ttl method for looking up time to live
This commit is contained in:
@ -14,4 +14,16 @@ describe SecureSession do
|
||||
s["hello"] = nil
|
||||
expect(s["hello"]).to eq(nil)
|
||||
end
|
||||
|
||||
it "can override expiry" do
|
||||
s = SecureSession.new("abc")
|
||||
key = SecureRandom.hex
|
||||
|
||||
s.set(key, "test2", expires: 5.minutes)
|
||||
expect(s.ttl(key)).to be_within(1.second).of (5.minutes)
|
||||
|
||||
key = SecureRandom.hex
|
||||
s.set(key, "test2")
|
||||
expect(s.ttl(key)).to be_within(1.second).of (SecureSession.expiry)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user