factory_bot
factory_bot copied to clipboard
Fix build_stubbed timestamps being different
Description
Ensures build_stubbed generates a record with equal created_at and updated_at.
Current behavior
Calling .build_stubbed on factories with entities that have created_at and updated_at assigns a slightly different time for each one of then because the code calls Time.current twice.
Expected behavior
I think the expected behavior should be for them to be exact the same.
Concerns
There are two concerns with the current solution:
- We would be calling
Time.currenteven if created_at and updated_at don't exist on the entity; - ~~It might be a problem that we're assigning the same object to both timestamps, should we
dupupdated_at?~~ (edit: dates are immutable, never mind :grimacing: :face_with_peeking_eye:).
I preferred to ask if these are valid concerns before investigating how to solve them.