diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index d5c1aaca12..a219bbdfa3 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -176,12 +176,12 @@ module ActionController # Methods #destroy and #load! are overridden to avoid calling methods on the # @store object, which does not exist for the TestSession class. - class TestSession < Rack::Session::Abstract::SessionHash #:nodoc: + class TestSession < Rack::Session::Abstract::PersistedSecure::SecureSessionHash #:nodoc: DEFAULT_OPTIONS = Rack::Session::Abstract::Persisted::DEFAULT_OPTIONS def initialize(session = {}) super(nil, nil) - @id = SecureRandom.hex(16) + @id = Rack::Session::SessionId.new(SecureRandom.hex(16)) @data = stringify_keys(session) @loaded = true end diff --git a/actionpack/test/dispatch/session/test_session_test.rb b/actionpack/test/dispatch/session/test_session_test.rb index 2d36990250..f3b1452d63 100644 --- a/actionpack/test/dispatch/session/test_session_test.rb +++ b/actionpack/test/dispatch/session/test_session_test.rb @@ -68,4 +68,10 @@ class ActionController::TestSessionTest < ActiveSupport::TestCase session = ActionController::TestSession.new(one: "1") assert_equal(2, session.fetch("2") { |key| key.to_i }) end + + def test_session_id + session = ActionController::TestSession.new + assert_instance_of String, session.id.public_id + assert_equal(session.id.public_id, session["session_id"]) + end end