From 9f9b1ed10020fcc68feaca028c4307a9d3eb597f Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Wed, 6 Mar 2019 17:32:18 +0100 Subject: [PATCH] Assign officer assignment when creating voter from booth If `officer_assigment' is not set the model cannot be validated, because it cannot be blank. --- spec/factories/polls.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb index 2de2c305b..26c047017 100644 --- a/spec/factories/polls.rb +++ b/spec/factories/polls.rb @@ -93,6 +93,11 @@ FactoryBot.define do trait :from_booth do association :booth_assignment, factory: :poll_booth_assignment origin "booth" + before :create do |voter| + voter.officer_assignment = create(:poll_officer_assignment, + officer: voter.officer, + booth_assignment: voter.booth_assignment) + end end trait :valid_document do