Do not mutate AC::TestRequest::DEFAULT_OPTIONS

This commit is contained in:
Kir Shatrov 2016-09-09 22:17:10 -04:00
parent cf5f55cd30
commit 040ca9cf5b
2 changed files with 6 additions and 1 deletions

View File

@ -51,7 +51,7 @@ module ActionController
super(env)
self.session = session
self.session_options = TestSession::DEFAULT_OPTIONS
self.session_options = TestSession::DEFAULT_OPTIONS.dup
@controller_class = controller_class
@custom_param_parsers = {
xml: lambda { |raw_post| Hash.from_xml(raw_post)["hash"] }

View File

@ -6,6 +6,11 @@ class ActionController::TestRequestTest < ActionController::TestCase
assert @request.session_options
end
def test_mutating_session_options_does_not_affect_default_options
@request.session_options[:myparam] = 123
assert_equal nil, ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
end
ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS.each_key do |option|
test "rack default session options #{option} exists in session options and is default" do
assert_equal(ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS[option],