Skip to content

Commit

Permalink
Added ActionDispatch::Request::Session#keys and ActionDispatch::Reque…
Browse files Browse the repository at this point in the history
…st::Session#values
  • Loading branch information
parndt committed May 23, 2012
1 parent d7de7a7 commit 6ac458d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions actionpack/lib/action_dispatch/request/session.rb
Expand Up @@ -87,6 +87,14 @@ def has_key?(key)
alias :key? :has_key? alias :key? :has_key?
alias :include? :has_key? alias :include? :has_key?


def keys
@delegate.keys
end

def values
@delegate.values
end

def []=(key, value) def []=(key, value)
load_for_write! load_for_write!
@delegate[key.to_s] = value @delegate[key.to_s] = value
Expand Down
16 changes: 16 additions & 0 deletions actionpack/test/dispatch/request/session_test.rb
Expand Up @@ -36,6 +36,22 @@ def test_find
assert_equal s, Session.find(env) assert_equal s, Session.find(env)
end 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 private
def store def store
Class.new { Class.new {
Expand Down

0 comments on commit 6ac458d

Please sign in to comment.