Authlogic causing all rails tests to fail

399 views Asked by At

I'm building an app in Rails 3 using Authlogic for authentication. I have a User model with a database table and a user_session model without one

All of my tests fail, whether I run

Error: test_the_truth(UsersControllerTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: user_sessions: DELETE FROM "user_sessions" WHERE 1=1

It's expecting user_session to have a table even though it inherits from Authlogic. Does anybody know how to fix this?

2

There are 2 answers

0
farnoy On BEST ANSWER

Ensure you have defined properly test database in config/database.yml, then try rake db:test:prepare or rake db:migrate RAILS_ENV=test.

0
Cristobal Viedma On

I was having the same problem and this took me a while to discover... the thing is Authlogic has no table in the database. When we create the sessions with Rails generate, this is creating also automatically a fixture, which of course will fail later since there is no table to fill data in. Solution: delete the fixture of user_sessions.

Read more about the problem here