1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Update session to have indifferent access

This commit is contained in:
Tom Prats 2015-07-12 02:01:30 -04:00
parent 513f72804d
commit 82dc8266dd
3 changed files with 21 additions and 2 deletions

View file

@ -1,3 +1,12 @@
* Update session to have indifferent access across multiple requests
session[:deep][:hash] = "Magic"
session[:deep][:hash] == "Magic"
session[:deep]["hash"] == "Magic"
*Tom Prats*
* Response etags to always be weak: Prefixes 'W/' to value returned by
`ActionDispatch::Http::Cache::Response#etag=`, such that etags set in
`fresh_when` and `stale?` are weak.

View file

@ -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
@ -61,7 +61,7 @@ module ActionDispatch
def initialize(by, req)
@by = by
@req = req
@delegate = {}
@delegate = {}.with_indifferent_access
@loaded = false
@exists = nil # we haven't checked yet
end

View file

@ -105,6 +105,16 @@ module ActionDispatch
end
end
def test_with_indifferent_access
s = Session.create(store, req, {})
s[:one] = { test: "deep" }
s[:two] = { "test" => "deep" }
assert_equal 'deep', s[:one]["test"]
assert_equal 'deep', s[:two][:test]
end
private
def store
Class.new {