Fixtures load inconsistently


#1

Hi all,

I’ve got a weird problem with loading fixtures, and I’m hoping someone
out there can help. I’m having problems running my tests, because for
one of my models the fixtures are loading strangely. Here’s an
example fixture:

john_doe:
status: student
department:
alumni:
title:
applicant:
student_status:
staff:
pref_first_name:
faculty:
applicant_status:
year_in_school: freshman
chair:
pidm: 12345678
reed_id: L12345
program:
middle_initial:
first_name: John
student: Y
login: doej
last_name: Doe
email: removed_email_address@domain.invalid

This is a model that’s wrapping a legacy table. It has no id column.
However, its pidm column is the primary key, so in my model I’ve got:

set_primary_key :pidm
alias_attribute :id, :pidm

If I load up my fixtures using “rake:fixtures:load RAILS_ENV=test”
then everything works just fine. My 5 fixtures for this model go in
to the test db exactly as written. However, when I run my test suite,
and rails loads the fixtures, 3 of the 5 fixtures load up with their
pidm field set to 91.

It’s surprising because it’s only 3 of the 5. I’ve been poking at it
all morning, with no luck. I’ve changed data values, etc., and it’s
always the same 3 that come out with 91. The other 2 fixtures have
the pidm that’s set in the fixture’s yaml file.

Has anybody encountered this? Or does anybody have suggestions?

Thanks!