I am testing a Rails application and I can't quite figure out how to set up my fixtures correctly.
I have organizations, memberships and agents:
Agent:
has_many :memberships
has_many :organizations, through: :memberships
Organization:
has_many :memberships
has_many :agents, through: :memberships
Membership:
belongs_to :organization
belongs_to :agent
enum role: [:owner, :admin, :agent]
Now I'd like to set up my fixtures and this is what I have so far:
Agent:
SonGoku:
first_name: Son
last_name: Goku
email: gen@kidama.com
current_organization_id: one
Organization
one:
name: "Freezer AG"
Membership
mem:
agent_id: SonGoku
organization_id: one
role: <%= ??? %> ??1??
So my first question is: Is that ok so far? And my second question is: How can I implement the role correctly, which is an enum in that has_many_through relationship?
Thank you very much, any help is appreciated!
Best
Aucun commentaire:
Enregistrer un commentaire