views:

12

answers:

0

Hi,

coming from rails 2.3.5 I am used to do something like that:

class MyControllerTest < ActionController::TestCase

    test 'should get index if logged in' do
      session = method_to_create_a_valid_session # in test_helper.rb
      get :index, {}, {:id => session.id}
      assert_response :success # redirect would happen if not logged in
    end
end

In rails 3 that does not work anymore. The session store is configured as

Rails.application.config.session_store :active_record_store, :key => '_my_session'

and the corresponding tables are there. I am able to login in a non test scope.

The problem in test scope is that I am not able to set the session_id manually. I figured out that the session identifier changed from id to session_id in rails 3. But even setting the session_id like

get :index, {}, {:id => session.session_id}

will not work. Instead of using that session, a new session is created.

Any suggestions?

Thanks!