mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
allow disabling session_secret
This commit is contained in:
parent
652411f832
commit
13b79de10c
2 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue