Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Never use Session middleware in test environment [#119]

  • Loading branch information...
commit 08b142b4cc5501277b74ece88b1edfae3e239348 1 parent 8edb409
Ryan Tomayko rtomayko authored
Showing with 4 additions and 1 deletion.
  1. +3 −0  compat/sessions_test.rb
  2. +1 −1  lib/sinatra/base.rb
3  compat/sessions_test.rb
View
@@ -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
@@ -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  lib/sinatra/base.rb
View
@@ -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) }
Please sign in to comment.
Something went wrong with that request. Please try again.