Fix flaky organization_spec.rb and donnation_summary_spec.rb specs#5521
Open
stefannibrasil wants to merge 6 commits intorubyforgood:mainfrom
Open
Fix flaky organization_spec.rb and donnation_summary_spec.rb specs#5521stefannibrasil wants to merge 6 commits intorubyforgood:mainfrom
stefannibrasil wants to merge 6 commits intorubyforgood:mainfrom
Conversation
Rails extends the Time and DateTime objects, and includes the `current`` property for retrieving the time the Rails environment is set to (default = UTC), as opposed to the server time (could be anything). https://stackoverflow.com/a/18811305
Freezing the time and checking for the same time period should fix the flakiness.
Time was being frozen after creating the factory. Move the test setup inside a freeze_time block to ensure created_at is created 1.day.ago. Plus, using the same date/time helper as the IssuedAt concern helps with keeping the test consistent with the code.
Contributor
Author
|
@dorner could you approve the workflows so I can run this a few times in CI? 🙏🏼 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #5515
Description
Testing against time related scenarios can lead to flakiness. I couldn't reproduce the failures locally but based on my previous experience of fixing flaky tests, I:
DateTime.currentinstead ofDateTime.now. Rails extends the Time and DateTime objects, and includes the `current`` property for retrieving the time the Rails environment is set to (default = UTC), as opposed to the server time (could be anything). See https://stackoverflow.com/a/18811305freeze_timeblock to ensure the dates are frozen when asserting against them.Type of change
How Has This Been Tested?
I could not reproduce the failure at all locally. All tests pass locally. But I believe this should help CI get more stable.