Issues with Tests

Keynan Pratt wrote:

Test Code:

def setup
  @controller =
  @request =
  @response =

  @request.session[:user_id] = User.find(1)
  @request.session[:time_of_last_action] = ( - 30*60)

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

  assert_equal 'Your settings have been successfully updated',


Action Code:

def index
  if (session[:user_id].settings.update_attributes(params[:settings]))
    flash[:notice] = 'Your settings have been successfully updated'
    flash[:notice] = 'Your settings could not be updated'
  @settings = session[:user_id].settings


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?

You haven't told us which assert you think is supposed to be failing and why.

If you want to track the changes to the session object, you can just print out its contents in your code and see if things are getting set as they should be.

Keynan Pratt wrote:

the purpose of the first assert is to print the session in the fail message

all the assertions fail.

the assigns hash seems to be working but information from session and flash does not change with the request

In Ruby false != 0