Fix build_stubbed timestamps being different #1653
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 callsTime.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:
Time.current
even 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(edit: dates are immutable, never mind 😬 🫣).dup
updated_at?I preferred to ask if these are valid concerns before investigating how to solve them.