-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Respect completed_at timestamp in order factories #4168
Conversation
The order factories that automatically complete orders previously used Time.current when setting the completed_at timestamp. For developers who want to pre-date their order completions, this can be confusing. This change allows orders to be cleanly pre-dated in this way.
Mysql tests failed because I was too granular with my timestamp comparison. I updated it to 5 seconds and force-pushed the fix. Sorry if anyone happened to catch the review super early! |
The failing postgres test looks like spec flake to me, I can reproduce it locally by |
Happy to simply rebase if/when this is merged, or if someone with ci powers wants to re-run for me I'd be happy with that too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though 5 seconds is probably excessive.
core/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb
Outdated
Show resolved
Hide resolved
A five second window was previously stored. A 1s window is too small because it might occur at the rollover to a new second, and mysql could flake on this. So, a two second window is appropriately small while still accounting for timestamps being truncated when stored. For example * Clock reads xx:yy:01.995 * Factory runs * MySQL stores xx:yy:01.000 * Clock now reads xx:yy:02.005 * Compare timestamps, 1.005s difference, test fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
The order factories that automatically complete orders previously used
Time.current when setting the completed_at timestamp. For developers who want
to pre-date their order completions, this can be confusing. This change allows
orders to be cleanly pre-dated in this way.
Checklist: