Hi there,
How can I make a bunch of "childrens" (in my case Votings) with the same Parent (in my case User, Answer, Question, Survey)?
I wanna provide a "special set of Votings" for my tests.
Fabricator :full_voting, from: :voting do
participant { Fabricate :participant_basic }
survey
question
answer
department { Fabricate :department }
user
answer1 1
answer2 0
answer3 -1
end
This is my model:
class Voting < ActiveRecord::Base
attr_accessible :survey_id,
:department_id,
:question_id,
:answer_id,
:answer1,
:answer2,
:answer3
belongs_to :participant
belongs_to :user
belongs_to :department
belongs_to :industry
belongs_to :survey
belongs_to :question
belongs_to :answer
#has_many :opinions
#has_many :answers, through: :opinions
validates_presence_of :participant, :user, :survey, :question, :answer1, :answer2, :answer3
end
I know I can do something like:
Fabrcator :answer do
voting(count: 100) {Fabricate :voting)
end
But this does not work because, Voting needs also a User, Question and so on and they are always newly generated with each call.
Please help me out of that maze.
many thanks in advance