def establish_test_session
if @rack_middleware
session_options = ActionController::Base.session_options
@session_id = ActiveSupport::SecureRandom.hex(16)
do_not_do_much = lambda do |env|
env["rack.session"] = @session_data
env["rack.session.options"] = {:id => @session_id}
[200, {}, ""]
end
@session_store = ActionController::Base.session_store.new(do_not_do_much, session_options)
@session_store.call({})
else
session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.stringify_keys
session_options = session_options.merge('new_session' => true)
@session = CGI::Session.new(Hash.new, session_options)
@session_data.each{ |k,v| @session[k] = v }
@session.update
@session_id = @session.session_id
end
end