Assign officer assignment when creating voter from booth

If `officer_assigment' is not set the model cannot be validated,
because it cannot be blank.
This commit is contained in:
Julian Herrero
2019-03-06 17:32:18 +01:00
parent 58f22915e9
commit 9f9b1ed100

View File

@@ -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