Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding index to email column culprit for unit tests failing

Tags:

I am new to devise and rails and I just integrated devise with my sample app. What I noticed is after creating a user model, all my unit tests were failing. I went to try to narrow this and found that even the generated assert 'the truth' one for user_test.rb also fails:

ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: \     column email is not unique: INSERT INTO "users" (... 

Once I commented out the add_index ...

# add_index :users, :email, :unique => true 

... and re-ran rake db:test:load and re-run tests with ruby -I test test/unit/user_test.rb it passes.

Has anyone else experience this?

like image 772
glory Avatar asked Apr 24 '11 09:04

glory


People also ask

How are test failures identified in a test output file?

Failing tests are indicated with FAIL in the output. So all you have to do is filter the output for that word. Note that this is purely text processing, it doesn't know anything about go tests and their results. This means you might get "false positives" if a test outputs the word FAIL even if it succeeds.


1 Answers

If you just generated the devise model, a fixture was also generated with more or less this content:

one: {} # column: value # two: {} #  column: value 

This fixture tries to create two users, with the same (inexistant) email. Replace it by:

one:   email: [email protected]  two:   email: [email protected] 

It will fix this error.

like image 114
Géal Avatar answered Sep 22 '22 06:09

Géal