factory_bot creates two records by calling `create` once
The following discussion from !685 (merged) should be addressed:
-
@zsbenke started a discussion: I need help fixing a failing test. For some reason factory_bot started creating duplicate users on
create
.I printed out the count of users in an unrelated test's setup:
require 'application_system_test_case' class ClientsTest < ApplicationSystemTestCase setup do @superadmin = create :user, email: 'superadmin@example.com' puts User.count @department_manager = create :department_manager, email: 'department@example.com' puts User.count @social_worker = create :social_worker puts User.count end …
User.count
getting increased by 2 in the test output each timecreate
gets called:~/Developer/aoz-003 (feature/change-passwords-as-a-superuser *)$ bin/rails test test/system/clients_test.rb Run options: --seed 14280 # Running: 2 4 6
This causes a test failing in users_test, since it works on a specific number of users and one of those shadowed
User
record doesn't have a volunteer created which blows up the test.https://git.panter.ch/open-source/aoz-003/-/jobs/35288
I could spend time to get those ghost records destroyed in the test, but it would me more feasible if we could find out why there are 2 records created by calling
create
once on user factories.Meanwhile, I comment out this test and merge this branch.