From 341e3369d11947e74a07073d96cd8f20eb1565d0 Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Sat, 3 Oct 2009 15:01:51 +0200 Subject: [PATCH] Stop disabling sessions in test environement Manually `disable :sessions` if you want to manually pass in the `rack.session` env key in your tests. --- lib/sinatra/base.rb | 2 +- test/helpers_test.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 16faf9e9..56a07b1f 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -916,7 +916,7 @@ module Sinatra # an instance of the class new was called on. def new(*args, &bk) builder = Rack::Builder.new - builder.use Rack::Session::Cookie if sessions? && !test? + builder.use Rack::Session::Cookie if sessions? builder.use Rack::CommonLogger if logging? builder.use Rack::MethodOverride if methodoverride? builder.use ShowExceptions if show_exceptions? diff --git a/test/helpers_test.rb b/test/helpers_test.rb index 9fde81b6..36027627 100644 --- a/test/helpers_test.rb +++ b/test/helpers_test.rb @@ -188,15 +188,22 @@ class HelpersTest < Test::Unit::TestCase it 'creates a new session when none provided' do mock_app { + enable :sessions + get '/' do assert session.empty? session[:foo] = 'bar' - 'Hi' + redirect '/hi' + end + + get '/hi' do + "hi #{session[:foo]}" end } get '/' - assert_equal 'Hi', body + follow_redirect! + assert_equal 'hi bar', body end end