Created
March 18, 2010 03:33
-
-
Save jamesarosen/336013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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