diff --git a/lib/lotus/action/session.rb b/lib/lotus/action/session.rb index e9f6607c..7123d8ab 100644 --- a/lib/lotus/action/session.rb +++ b/lib/lotus/action/session.rb @@ -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 @@ -60,6 +58,7 @@ def self.included(action) # end # end def session + @_env ||= {} @_env[SESSION_KEY] ||= {} end diff --git a/test/fixtures.rb b/test/fixtures.rb index 453a1812..4f636a64 100644 --- a/test/fixtures.rb +++ b/test/fixtures.rb @@ -962,6 +962,8 @@ def call(params) self.headers.merge!('X-Custom' => 'OK') headers.merge!('Y-Custom' => 'YO') + self.session[:foo] = 'bar' + # PRIVATE # self.configuration # self.finish @@ -969,7 +971,6 @@ def call(params) # PROTECTED self.response self.cookies - self.session response cookies diff --git a/test/session_test.rb b/test/session_test.rb index e3de543f..9cc4e953 100644 --- a/test/session_test.rb +++ b/test/session_test.rb @@ -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