allow disabling session_secret

This commit is contained in:
Konstantin Haase 2011-04-14 09:00:00 +02:00
parent 652411f832
commit 13b79de10c
2 changed files with 16 additions and 1 deletions

View File

@ -1296,7 +1296,8 @@ module Sinatra
def setup_sessions(builder)
return unless sessions?
options = { :secret => session_secret }
options = {}
options[:secret] = session_secret if session_secret?
options.merge! sessions.to_hash if sessions.respond_to? :to_hash
builder.use Rack::Session::Cookie, options
end

View File

@ -313,6 +313,20 @@ class HelpersTest < Test::Unit::TestCase
assert_body 'ok'
end
it 'allows disabling session secret' do
mock_app do
enable :sessions
disable :session_secret
get '/' do
assert !env['rack.session.options'].include?(:session_secret)
'ok'
end
end
get '/'
assert_body 'ok'
end
it 'accepts an options hash' do
mock_app do
set :sessions, :foo => :bar