mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move spec/components to spec/lib (#15987)
Lib specs were inexplicably split into two directories (`lib` and `components`) This moves them all into `lib`.
This commit is contained in:
29
spec/lib/secure_session_spec.rb
Normal file
29
spec/lib/secure_session_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe SecureSession do
|
||||
it "operates correctly" do
|
||||
s = SecureSession.new("abc")
|
||||
|
||||
s["hello"] = "world"
|
||||
s["foo"] = "bar"
|
||||
expect(s["hello"]).to eq("world")
|
||||
expect(s["foo"]).to eq("bar")
|
||||
|
||||
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