Skip to content

Instantly share code, notes, and snippets.

@chischaschos
Created June 15, 2011 17:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chischaschos/1027591 to your computer and use it in GitHub Desktop.
Save chischaschos/1027591 to your computer and use it in GitHub Desktop.
Trying to send session vals through rack session
## My spec
context 'when demo user is logged in' do
before do
@user = User.make
login_as @user
end
it 'should be redirected' do
delete '/user/logout', {}, 'rack.session' => {:someval => 123}
last_response.status.should == 302
last_response.headers['Location'].should == 'http://example.org/'
end
end
## My route
delete '/user/logout' do
redirect to_homepage unless logged_in?
puts "-->#{session.inspect}"
user_session = session.delete(:user)
redirect to_homepage
end
## Prints out
-->{"session_id"=>"b69aa81c7e262930ebe3d0022bfd7f7c0ad8c0c6d14ac416838bc385a8d2d007", "__FLASH__"=>{}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment