Problem with Test Fixtures

Hi All,

I'm currently working on an Admin Controller that displays a list of topics and questions. Users are required to login to add topics/ questions. The login functionality works fine in practice - all actions except 'signin' are wrapped in a before filter that redirects in the absence of session[:user].

My problem is that all my tests are producing errors as the test suite will not recognise the fixtures for the AdminUser model as follows:

"No fixture with name 'robin' found for table 'admin_users'"

I've set out below 2 sample tests from the admin_controller_test (note the methods at the bottom - covering the bases using strings and symbols), fixtures and 'tail' from the test.log. I have tried to pass the session directly as a parameter to an individual test and still receive the same error.

Any help would be greatly appreciated.

Robin

- - - - - - - -   def test_should_show_new     get_with_user :new     assert_response :success     assert_template 'new'     assert_not_nil assigns(:topic)   end

  def test_should_add_topic     post_with_user :new, :topic => {:name => 'test topic', :description => 'test description'}     assert ! assigns(:topic).new_record?     assert_redirected_to :action => 'index'     assert_not_nil flash[:notice]   end

  protected   def get_with_user(action, parameters = nil, session = nil, flash = nil)     get action, nil, {'user' => admin_users(:robin).id}   end

  def post_with_user(action, parameters = nil, session = nil, flash = nil)     post action, nil, :user => admin_users('robin').id   end - - - - - - - one:   id: 1   username: robin   password_salt: 1YP9AH4N   password_hash: 4deec5b9b2fb00544b018ee17e27e6fb9ed338d7a1402d16b72b715e75ea2ef4 #secret

two:   id: 2   username: jaye   password_salt: CB620C9W   password_hash: 1ff5c3462acdb8aa47fc07a2fd4a8103ac43d8754fb263b350bfb79e8b413c33 #bunny - - - - - - - robin-fishers-computer:~/elearning robinfisher$ rake test:functionals tail -f log/test.log (in /Users/robinfisher/elearning) rake aborted! /Users/robinfisher/elearning/log/test.log:1: Invalid char `\033' in expression /Users/robinfisher/elearning/log/test.log:1: parse error, unexpected ';', expecting ']'   SQL (0.000167) SET SQL_AUTO_IS_NULL=0       ^ /Users/robinfisher/elearning/log/test.log:1: parse error, unexpected tIDENTIFIER, expecting $   SQL (0.000167) SET SQL_AUTO_IS_NULL=0               ^

(See full trace by running task with --trace)

one: id: 1 username: robin password_salt: 1YP9AH4N password_hash: 4deec5b9b2fb00544b018ee17e27e6

fb9ed338d7a1402d16b72b715e75ea2ef4 #secret

Should be

robin:

id: 1 username: robin password_salt: 1YP9AH4N password_hash: 4deec5b9b2fb00544b018ee17e27e6 fb9ed338d7a1402d16b72b715e75ea2ef4 #secret

When you do admin_users(:robin) you need to pass the NAME of the fixture entry… Your first fixture entry is ‘one’ and not ‘robin’.

Does that make sense?

Makes perfect sense!

Thanks for the quick response, I'm now showing a healthy 0 failures, 0 errors.

Robin