Skip to content

Commit

Permalink
Never use Session middleware in test environment [sinatra#119]
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Feb 27, 2009
1 parent 8edb409 commit 08b142b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compat/sessions_test.rb
Expand Up @@ -21,6 +21,7 @@

specify "should be able to store data accross requests" do
set_option :sessions, true
set_option :environment, :not_test # necessary because sessions are disabled

get '/foo' do
session[:test] = true
Expand All @@ -34,6 +35,8 @@
get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
assert ok?
assert include?('Set-Cookie')

set_option :environment, :test
end

end
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Expand Up @@ -776,7 +776,7 @@ def prototype
# an instance of the class new was called on.
def new(*args, &bk)
builder = Rack::Builder.new
builder.use Rack::Session::Cookie if sessions?
builder.use Rack::Session::Cookie if sessions? && !test?
builder.use Rack::CommonLogger if logging?
builder.use Rack::MethodOverride if methodoverride?
@middleware.each { |c, args, bk| builder.use(c, *args, &bk) }
Expand Down

0 comments on commit 08b142b

Please sign in to comment.