J'ai une usine utilisateur qui fait référence à une sociétéAccès des modèles liés n'est pas encore mentionné
Factory.define :user do |f|
f.first_name "John"
f.last_name "Smith"
f.password "test01"
f.password_confirmation {|u| u.password}
f.email "[email protected]"
f.association :company, :factory => :company
end
Factory.define :company do |f|
f.name "My Company"
end
La Société a de nombreux utilisateurs. Maintenant je veux que la compagnie ait beaucoup de clients. Il n'est pas nécessaire de mentionner l'entreprise, sauf pour vérifier qu'une fois que le client est créé, il appartient à l'entreprise.
Scenario: Creating a client adds them to a user's company
Given a user "John" has registered with "[email protected]",
"test01"
And I login with "[email protected]", "test01"
And I am on the list of clients
When I follow "Add New Client"
When I fill in "Name" with "My Fav Client"
And I press "Create"
Then a client should exist with name: "My Fav Client"
And that client should be in my company's clients # needs the
right syntax
La dernière phrase est ma préoccupation. Comment puis-je dire Pickle que l'utilisateur I est connecté avec un modèle de société associé à partir de l'usine , alors vérifiez auprès de cette société pour voir s'il ya un client associé.
Merci