Skip to content

Commit

Permalink
fix memcache tests on 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Dec 17, 2019
1 parent f2cb48e commit 99a8a87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions lib/rack/session/memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def generate_sid
end
end

def find_session(req, sid)
with_lock(req) do
def get_session(env, sid)
with_lock(env) do
unless sid and session = get_session_with_fallback(sid)
sid, session = generate_sid, {}
unless /^STORED/ =~ @pool.add(sid.private_id, session)
Expand All @@ -58,18 +58,18 @@ def find_session(req, sid)
end
end

def write_session(req, session_id, new_session, options)
def set_session(env, session_id, new_session, options)
expiry = options[:expire_after]
expiry = expiry.nil? ? 0 : expiry + 1

with_lock(req) do
with_lock(env) do
@pool.set session_id.private_id, new_session, expiry
session_id
end
end

def delete_session(req, session_id, options)
with_lock(req) do
def destroy_session(env, session_id, options)
with_lock(env) do
@pool.delete(session_id.public_id)
@pool.delete(session_id.private_id)
generate_sid unless options[:drop]
Expand Down
14 changes: 7 additions & 7 deletions test/spec_session_memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@
pool.pool.delete(session_id.private_id)

res1 = req.get("/", "HTTP_COOKIE" => cookie)
res1["Set-Cookie"].must_be_nil
res1.body.must_equal '{"counter"=>2}'
pool.pool.get(session_id.private_id, true).wont_be_nil
res1["Set-Cookie"].should.be.nil
res1.body.should.equal '{"counter"=>2}'
pool.pool.get(session_id.private_id, true).should.not.be.nil
end

it "drops the session in the legacy id as well" do
Expand All @@ -265,10 +265,10 @@
pool.pool.delete(session_id.private_id)

res2 = dreq.get("/", "HTTP_COOKIE" => cookie)
res2["Set-Cookie"].must_be_nil
res2.body.must_equal '{"counter"=>2}'
pool.pool.get(session_id.private_id, true).must_be_nil
pool.pool.get(session_id.public_id, true).must_be_nil
res2["Set-Cookie"].should.be.nil
res2.body.should.equal '{"counter"=>2}'
pool.pool.get(session_id.private_id, true).should.be.nil
pool.pool.get(session_id.public_id, true).should.be.nil
end

# anyone know how to do this better?
Expand Down

0 comments on commit 99a8a87

Please sign in to comment.