Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build_stubbed timestamps being different #1653

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kimesf
Copy link

@kimesf kimesf commented May 22, 2024

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:

  1. We would be calling Time.current even if created_at and updated_at don't exist on the entity;
  2. It might be a problem that we're assigning the same object to both timestamps, should we dup updated_at? (edit: dates are immutable, never mind 😬 🫣).

I preferred to ask if these are valid concerns before investigating how to solve them.

Factories on entities with created_at and updated_at assign a slightly
different time for each, because it calls Time.now twice.

This fix ensures they will be assigned the exact same time.
@kimesf kimesf changed the title fix: build_stubbed timestamps are different Fix build_stubbed timestamps being different May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant