Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
Created March 18, 2010 03:33
Show Gist options
  • Save jamesarosen/336013 to your computer and use it in GitHub Desktop.
Save jamesarosen/336013 to your computer and use it in GitHub Desktop.
require 'test_helper'
class SessionsAreDyingControllerTest < ActionController::TestCase
setup
super
@user = Factory(:user)
end
context 'a signed-in user' do
setup { @controller.session[:current_user_id] = @user.id }
context 'updating her own page' do
setup do
@old_session = @controller.session
assert_equal @user.id, old_session[:current_user_id] # works great!
post :update, :id => @user, :user => { :some => 'user params' }
end
should 'stay signed-in' do
assert_equal @user.id, @controller.session[:current_user_id] # RAR!!!
end
should 'keep the session around' do
assert_equal @old_session.object_id, @controller.session.object_id # also RAR!!!
end
end
end
end
require 'shoulda'
require 'factory_girl'
# ensure controllers have sessions so we can sign in
# before making requests:
ActionController::TestCase.class_eval do
def setup
@controller.session ||= HashWithIndifferentAccess.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment