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

Give fixed ages to FactoryBot-generated users #22552

Merged
merged 1 commit into from May 21, 2018

Conversation

islemaster
Copy link
Contributor

Context: #22471 (comment)

image

Our tests are more likely to care about the age of a user than their birthdate, providing relative birthdates in our user fixtures makes more sense.

@@ -48,7 +48,7 @@
end

factory :user do
birthday Date.new(1991, 3, 14)
birthday Time.zone.today - 21.years
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this will fix the date when factories.rb is loaded since it's not a dynamic attribute. I think that's fine, and probably better since we create a lot of test users and while minimal there's no point recalculating today - 21.years each time. Test runs don't last days. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!

@islemaster islemaster merged commit 00a4c56 into staging May 21, 2018
@islemaster islemaster deleted the factorybot-default-user-age branch May 21, 2018 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants