views:

91

answers:

1

OK, I am writing performance tests and am having trouble getting my session to persist like it does in integration tests. As I understand it, PerformanceTest is a child of IntegrationTest and any integration tests should work with performance test. However, when I take a integration test and copy it over to performance, change the ActionController::IntegrationTest to ActionController::PerformanceTest and then run the test, it fails.

I am using Authlogic and have not had a problem with the integration test sessions sticking around. With the performance tests though it looks like the session gets created properly but when I visit the "/reports" page (which is a protected page) it redirects me to the login page like there is no user session at all.

require 'performance_test_help'

class SimpleTest < ActionController::PerformanceTest
  setup :activate_authlogic

  test "login" do
    assert user_session = UserSession.create!(User.find_by_login("admin"))

    get "/reports"
    assert_response :success
  end
end

What's going on here? I've tried multiple ways to get a user session (create, post, etc.) and nothing seems to work. This is the first time I've written performance tests so I'm probably doing something stupid...

BTW: I am running Ruby 1.8.7, Rails 2.2.2 on Debian Squeeze.

A: 

You have to setup your performance tests like your integration tests.

Try to login using post:

post "user_session", :user_session => {:login => "user", :password => "password"}
leaber