Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

load session data for merge!

ID#prepare_session calls merge! on the newly-created SessionHash, but
this method is not overridden to parse existing data. As such, any
previous session data passed in from an earlier middleware is discarded.

For me, this was breaking Rack::Test while testing a Sinatra app.
  • Loading branch information...
commit 63d367e0b791ceb9c368bc461142ed8c042fe1d0 1 parent e6b25b5
@jamie jamie authored raggi committed
Showing with 12 additions and 0 deletions.
  1. +5 −0 lib/rack/session/abstract/id.rb
  2. +7 −0 test/spec_session_cookie.rb
View
5 lib/rack/session/abstract/id.rb
@@ -116,6 +116,11 @@ def empty?
super
end
+ def merge!(hash)
+ load_for_write!
+ super
+ end
+
private
def load_for_read!
View
7 test/spec_session_cookie.rb
@@ -310,4 +310,11 @@ def call(env)
res = Rack::MockRequest.new(app).get("/", 'rack.session' => {:foo => 'bar'})
res.body.should.match(/foo/)
end
+
+ it "allows modifying session data with session data from middleware in front" do
+ request = { 'rack.session' => { :foo => 'bar' }}
+ response = response_for(:app => incrementor, :request => request)
+ response.body.should.match(/counter/)
+ response.body.should.match(/foo/)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.