Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/lotus/action/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def self.included(action)
end
end

protected

# Gets the session from the request and expose it as an Hash.
#
# @return [Hash] the HTTP session from the request
Expand Down Expand Up @@ -60,6 +58,7 @@ def self.included(action)
# end
# end
def session
@_env ||= {}
@_env[SESSION_KEY] ||= {}
end

Expand Down
3 changes: 2 additions & 1 deletion test/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -962,14 +962,15 @@ def call(params)
self.headers.merge!('X-Custom' => 'OK')
headers.merge!('Y-Custom' => 'YO')

self.session[:foo] = 'bar'

# PRIVATE
# self.configuration
# self.finish

# PROTECTED
self.response
self.cookies
self.session

response
cookies
Expand Down
11 changes: 8 additions & 3 deletions test/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
action = SessionAction.new
action.call({'rack.session' => session = { 'user_id' => '23' }})

action.__send__(:session).must_equal(session)
action.session.must_equal(session)
end

it 'returns empty hash when it is missing' do
action = SessionAction.new
action.call({})

action.__send__(:session).must_equal({})
action.session.must_equal({})
end

it 'exposes session' do
action = SessionAction.new
action.call({'rack.session' => session = { 'foo' => 'bar' }})

action.exposures[:session].must_equal(session)
action.session.must_equal(session)
end

it 'has a default of Hash' do
action = SessionAction.new
action.session.must_equal({})
end
end
end