Create only one poll for a poll voter
The factories were creating strange database relations:
* The voter belonged to a poll, to a booth and to an officer
* The booth belonged to a different poll
* The officer belonged to a different booth
The code uses an unusual syntax because the following code:
association :booth_assignment,
factory: :poll_booth_assignment,
poll: poll
Would generate the following error:
ActiveRecord::AssociationTypeMismatch: Poll(#46976420451940) expected,
got FactoryBot::Declaration::Implicit
This commit is contained in:
@@ -92,7 +92,10 @@ FactoryBot.define do
|
||||
|
||||
trait :from_booth do
|
||||
origin "booth"
|
||||
association :booth_assignment, factory: :poll_booth_assignment
|
||||
|
||||
booth_assignment do
|
||||
association :poll_booth_assignment, poll: poll
|
||||
end
|
||||
|
||||
officer_assignment do
|
||||
association :poll_officer_assignment, booth_assignment: booth_assignment, officer: officer
|
||||
|
||||
Reference in New Issue
Block a user