Using many-to-many relations in tests

Hello,

I have some many-to-many relations, I would like to use in my tests. But
I’m not sure what I should put in the fixtures for it?
How do I add those relations in the testing environment?

Greetings,
Gitte W.

I have some many-to-many relations, I would like to use in my
tests. But I’m not sure what I should put in the fixtures for it?
How do I add those relations in the testing environment?

you need to create fixtures for your join table as well:

if you have two models (Foo and Bar) and a bar_foos table for the join:

bar_foos.yml

first:
foo_id: 1
bar_id: 1
second:
foo_id: 1
bar_id: 2

etc.

in your unit tests, load all fixtures:

fixtures :foos, :bars, :bar_foos

hth jc