mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
fd0150da29
Move top-level set_option/set_options to Sinatra::Application#set and plumb in delegates from (main). NOTE: options set via these methods are no longer set in the default_options Hash but directly on the current application's options object.
39 lines
773 B
Ruby
39 lines
773 B
Ruby
require File.dirname(__FILE__) + '/helper'
|
|
|
|
context "Sessions" do
|
|
|
|
setup { Sinatra.application = nil }
|
|
|
|
specify "should be off by default" do
|
|
get '/asdf' do
|
|
session[:test] = true
|
|
"asdf"
|
|
end
|
|
|
|
get '/test' do
|
|
session[:test] == true ? "true" : "false"
|
|
end
|
|
|
|
get_it '/asdf', {}, 'HTTP_HOST' => 'foo.sinatrarb.com'
|
|
assert ok?
|
|
assert !include?('Set-Cookie')
|
|
end
|
|
|
|
specify "should be able to store data accross requests" do
|
|
set_option :sessions, true
|
|
|
|
get '/foo' do
|
|
session[:test] = true
|
|
"asdf"
|
|
end
|
|
|
|
get '/bar' do
|
|
session[:test] == true ? "true" : "false"
|
|
end
|
|
|
|
get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
|
|
assert ok?
|
|
assert include?('Set-Cookie')
|
|
end
|
|
|
|
end
|