Test Code:
def setup
@controller = SettingsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.session[:user_id] = User.find(1)
@request.session[:time_of_last_action] = (Time.now - 30*60)
end
def test_turn_wysiwyg_off
post ‘index’, {:settings => {:wysiwyg => 0}}
assert_equal(nil, session[:user_id].settings)
assert_equal(false, session[:user_id].settings.wysiwyg,
‘Session was not updated’)
assert_equal(false, UserSetting.find(1).wysiwyg, ‘Database was not
updated’)
assert_equal ‘Your settings have been successfully updated’,
flash[:notice]
end
=========================================================================
Action Code:
def index
if request.post?
if (session[:user_id].settings.update_attributes(params[:settings]))
if(session[:user_id].settings.save)
flash[:notice] = ‘Your settings have been successfully updated’
else
flash[:notice] = ‘Your settings could not be updated’
end
end
end
@settings = session[:user_id].settings
end
============================================================================
The action passes when tested manually.
It appears as though I don’t have access to any changes to the session
Does any one know how to make the magic happen?