mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #24820 from maclover7/fix-15843
Ensure compatibility between ActionDispatch::Request::Session and Rack
This commit is contained in:
commit
3bed679670
2 changed files with 31 additions and 1 deletions
|
@ -9,7 +9,7 @@ module ActionDispatch
|
|||
|
||||
# Singleton object used to determine if an optional param wasn't specified
|
||||
Unspecified = Object.new
|
||||
|
||||
|
||||
# Creates a session hash, merging the properties of the previous session if any
|
||||
def self.create(store, req, default_options)
|
||||
session_was = find req
|
||||
|
@ -198,6 +198,10 @@ module ActionDispatch
|
|||
@delegate.merge!(other)
|
||||
end
|
||||
|
||||
def each(&block)
|
||||
to_hash.each(&block)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_for_read!
|
||||
|
|
|
@ -114,5 +114,31 @@ module ActionDispatch
|
|||
}.new
|
||||
end
|
||||
end
|
||||
|
||||
class SessionIntegrationTest < ActionDispatch::IntegrationTest
|
||||
class MySessionApp
|
||||
def call(env)
|
||||
request = Rack::Request.new(env)
|
||||
request.session['hello'] = 'Hello from MySessionApp!'
|
||||
[ 200, {}, ['Hello from MySessionApp!'] ]
|
||||
end
|
||||
end
|
||||
|
||||
Router = ActionDispatch::Routing::RouteSet.new
|
||||
Router.draw do
|
||||
get '/mysessionapp' => MySessionApp.new
|
||||
end
|
||||
|
||||
def app
|
||||
@app ||= RoutedRackApp.new(Router)
|
||||
end
|
||||
|
||||
def test_session_follows_rack_api_contract_1
|
||||
get '/mysessionapp'
|
||||
assert_response :ok
|
||||
assert_equal 'Hello from MySessionApp!', @response.body
|
||||
assert_equal 'Hello from MySessionApp!', session['hello']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue