SOLVED: Fixtures Are Created in the DB Twice
Hi everyone. I am having a fixture issue that's driving me a bit crazy. I have some tests for a resource scoped to accounts. I am trying to add my own accounts fixtures. However, when I add the new fixture, it's loaded into the database twice. I have a Note model that is scoped to the account. When my test runs, the notes fixtures are associated with the duplicate account. e.g. I will have two accounts named "Alice." And the notes get associated with the duplicate, not the account under test.
This does not happen when I use the fixtures defined in the Jumpstart template and I can't for the life of me figure out why those would be different. I even tried renaming the
Has anyone else seen this before? It's been a while since I've used fixtures, so I'm not sure if I'm doing something wrong. But it's odd that the same thing doesn't happen for the fixtures defined in Jumpstart.
accounts(:one)
fixture to accounts(:alice)
and had the same problem. Also this is deterministic. It is always associated to wrong duplicate account row. Has anyone else seen this before? It's been a while since I've used fixtures, so I'm not sure if I'm doing something wrong. But it's odd that the same thing doesn't happen for the fixtures defined in Jumpstart.
I created fixtures for both the
users
and accounts
tables but not account_users
. So in SetCurrentRequestDetails
(link), it didn't find the associated account and created a new one. I assumed that the owner_id
would be sufficient, but I guess I didn't factor in the multiple account scenario.Notifications
You’re not receiving notifications from this thread.