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:
Javi Martín
2019-01-11 20:41:14 +01:00
parent b05ea2964c
commit 4830b563ea

View File

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