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

Added ActionDispatch::Request::Session#keys and ActionDispatch::Request::Session#values

This commit is contained in:
Philip Arndt 2012-05-23 14:24:08 +12:00
parent d7de7a79c5
commit 6ac458d341
2 changed files with 24 additions and 0 deletions

View file

@ -87,6 +87,14 @@ module ActionDispatch
alias :key? :has_key?
alias :include? :has_key?
def keys
@delegate.keys
end
def values
@delegate.values
end
def []=(key, value)
load_for_write!
@delegate[key.to_s] = value

View file

@ -36,6 +36,22 @@ module ActionDispatch
assert_equal s, Session.find(env)
end
def test_keys
env = {}
s = Session.create(store, env, {})
s['rails'] = 'ftw'
s['adequate'] = 'awesome'
assert_equal %w[rails adequate], s.keys
end
def test_values
env = {}
s = Session.create(store, env, {})
s['rails'] = 'ftw'
s['adequate'] = 'awesome'
assert_equal %w[ftw awesome], s.values
end
private
def store
Class.new {