If you want user_id to be ‘nil’, then omit it from your fixtures. I tried setting user_id: nil before, and it turned out to be ‘0’ in the database.

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<% u = UserLogin.create( :password => 'foo') %>
<% u.password=('password') %>
 
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 user_id: nil
 salt: <%= u.salt %>
 salted_password: <%= u.salted_password %>

Picture 3.png

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<% u = UserLogin.create( :password => 'foo') %>
<% u.password=('password') %>
 
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 salt: <%= u.salt %>
 salted_password: <%= u.salted_password %>

Picture 2.png

Before pulling your hair out on what went wrong with your functional tests, check the test database if you have the correct values in your records. Remember ‘0’ is different from ‘nil’.